How to install GD extension for PHP? - php

I have PHP 8.1.2 with Apache 2.4.52 on Ubuntu 22.04 and I think I need the GD Graphics Extension for my PHP scripts to work but it appears not to be installed and / or enabled (there is no GD section in the output from running phpinfo().
Some advice I have seen is to run apt-get install php-gd and restart Apache without any modifications to php.ini.
At php.net it seems to suggest there is a
recommended bundled version of the GD library
already present in my PHP and that I need to edit php.ini in order to enable it. I understood (I now think wrongly) this meant I needed to remove the prefixed semi colons from these pre existing directives:
;--with-gd[=DIR]
;--enable-gd
The advice continues on to suggest for certain image formats (although possibly not for PNG) I need to uncomment:
;--with-jpeg
;--with-xpm
;--with-webp
For enhancing GD's font capabilities uncomment:
--with-XXXX
--with-freetype
searching /etc/php/8.1/apache2/php.ini revealed that was no ;--enable-gd line or any of the other above directives in that file. There was a ;extension=gd line.
I would like to know how to proceed from here in order to install (if it is not already installed as I thought the documentation implied) and enable the GD Graphics extension.
Edit I also saw this geeksforgeeks article suggesting to uncomment ;extension=gd and restart the server.

You can run php -v to see what version of PHP you have on the machine.
After that, you can run sudo apt-get install php<your-php-version>-gd, e.g. sudo apt-get install php8.1-gd. Hope it helps!

Related

How to install Magento on a laptop?

When I install Magento 2, it gives me 4 errors. One is in a xsl file, one in a intl file, one in a soap file and one in a sockets file.
How can I remove all these errors? Please tell me.
These are the extensions that you need to install for php. which operating system you are using ?
xsl file,
intl file ,
soap file
and sockets file
if you are using windows then use.
Check php.ini file. This is normally under your xampp folder (Example D:\xampp\php)
Search like php_soap.dll;,php_xsl.dll,php_intl.dll each dll extension
removing the first ; character, to make it looks like
extension=php_soap.dll
extension=php_xsl.dll
extension=php_intl.dll
Once done restart Apache server.
if you are using ubuntu then use the following
apt-get install php7.0-intl
apt-get install php7.0-xsl

Enable XSL on Ubuntu 12.04

I am trying to enable XSL on Ubuntu 12.04 but its failing. I did this locally on my Ubuntu 13.04 and it was successful. Basically the following worked on my local computer.
apt-get install php5_xsl
edit php.ini file and add extension=php5_xsl.so
restart apache
I repeated the same procedures on my production server running Ubuntu 12.04 and PHP version 5.5.12 but the extension is not getting loaded from the phpinfo. I have also changed the extension=php5_xsl.so to extension=xsl.so because this is what in the extension directory.
I read that I might need to recompile PHP but I am not sure of this steps.
Try this:
sudo apt-get install php5-xsl
sudo php5enmod xsl
sudo service apache2 restart
Why:
http://www.lornajane.net/posts/2012/managing-php-5-4-extensions-on-ubuntu
What's happened here is that all debian-flavoured unixes have adopted
this standard for their PHP 5.4 packages, so if you're using debian,
ubuntu, or any of their relatives with PHP 5.4, you'll see a directory
structure like this. When you add a module to PHP, you'll add a file
to the mods-available directory enabling the module and adding any
config specific to it. If you want to enable the module, just do:
php5enmod http
This simply creates a symlink from the usual conf.d directory to point
to where the real files are in mods-available, prefixed with a number
that indicates the priority of the module. By default, the priority is
20.
Using this approach means we can toggle things on and off without
commenting out big chunks of config files and leaving them lying
around - if this seems familiar then that's no surprise; debian-like
linuxes manage their apache configuration in just the same way. Any
packages that you install using aptitude will use these exact same
commands to set up the configuration and then symlink it correctly. To
unlink, use the delightfully predictably-named php5dismod :)

phpMyAdmin - The MySQL Extension is Missing

I installed everything separately (Apache, PHP, MySQL and phpMyAdmin) and do not use a compilation, everything works fine till now except phpMyAdmin.
The problem I am experiencing is, that the error message states that the "MySQL extension is missing", as soon as I try to call up:
localhost/phpmyadmin/index.php
And when I call up
localhost/phpmyadmin/setup/index.php
I have two messages where I do not know if it is supposed to be like that:
Bzip2 compression and decompression requires functions (bzopen,
bzcompress) which are unavailable on this system.
and:
Zip decompression requires functions (zip_open) which are unavailable
on this system.
Any suggestions?
At first make sure you have mysql installed properly. You can ensure it just by checking that whether you can access mysql using mysql command promp. So if you mysql is working then probably it is not loading. For that follow the steps given below
First of all, you must find your php.ini. It could be anywhere but if you create a small php file with the
<?php phpinfo(); ?>
script it will tell you where it is. Just look at the path of loaded configuration file.
Common places include /etc/apache/, /etc/php4/apache2/php.ini, /etc/php5/apache2/php.ini or even /usr/local/lib/php.ini for Windows it may be C:\Users\username\PHP\php.ini
Edit your server’s php.ini and look for the following line. Remove the ‘;’ from the start of the line and restart Apache. Things should work fine now!
;extension=mysql.so
should become
extension=mysql.so
For windows it will be
;extension=mysql.dll
should become
extension=mysql.dll
Some linux distributions have a php_mysql and php_mysqli package to install.
You need to put the full path in the php ini when loading the mysql dll, i.e :-
extension=c:/php54/ext/php_mbstring.dll
extension=c:/php54/ext/php_mysql.dll
Then you don't need to move them to the windows folder.
In my case I had to install the extension:
yum install php php-mysql httpd
and then restart apache:
service httpd restart
That solved the problem.
Just as others stated you need to remove the ';' from:
;extension=php_mysql.dll and
;extension=php_mysqli.dll
in your php.ini to enable mysql and mysqli extensions. But MOST IMPORTANT of all, you should set the extension_dir in your php.ini to point to your extensions directory. The default most of the time is "ext". You should change it to the absolute path to the extensions folder. i.e. if you have your xampp installed on drive C, then C:/xampp/php/ext is the absolute path to the ext folder, and It should work like a charm!
I just add
apt-get install php5-mysqlnd
This will ask to overwrite mysql.so from "php5-mysql".
This work for me.
Installing bzip2 and zip PHP extensions solved my issue in Ubuntu:
sudo apt-get install php7.0-bz2
sudo apt-get install php7.0-zip
Use php(you version)-(extension) to install and enable any missing modules that is required in the phpmyadmin readme.
Your installation is missing some php modules, there should be a list of required modules in the phpmyadmin readme. If you recently enabled the modules, try restarting the apache service / daemon.
Edit: As it seems, there is no single "enable these modules" in the docs, so enable either mysql or mysqli in your php.ini (you might need to install it first).
The two messages are not important if you do not intend to upload or download compressed file within phpMyAdmin. If you do, enable the zlib and / or bz2 modules.
I had a similar issue, but it didn't help to add extension=mysql.so in my php.ini. It turned out that the mysql.so file was not in my extension folder nor anywhere else on my machine. Solved this by downloading the php source and building the extension manually and then copying it into the extension folder.
Just check your php.ini file, In this file Semicolon(;) used for comment
if you see then remove semicolon ;.
;extension=mysql.dll
Now your extension is enable but you need to restart appache
extension=mysql.dll

Install Tidy, PHP

I guess when php was installed on my box --with-tidy arg was not included.
When browsing my php.ini the line:
;extension=php_tidy.dll
is missing.
How can I add the module to my php install? Note I tried adding:
extension=php_tidy.dll
but with no luck.
I checked the docs but all they say is:
This extension is bundled with PHP 5 and greater, and is installed using the --with-tidy configure option.
On Ubuntu, you can add tidy to your php5 installation by running this command in a terminal:
$ sudo apt-get install php5-tidy
If you want to check if it is already installed or validate that the command above worked:
$ php -i | grep libTidy
libTidy Release => 25 March 2009 // means tidy is installed
To install both php5 and tidy at the same time, use this command (as an alternative to the "--with-tidy" configuration option):
$ sudo apt-get install php5 php5-tidy
For PHP 7 just run
sudo apt-get install php-tidy
And restart Apache, That's it :)
Update: Thanks to #Arnis Juraga
For the version above PHP 7, you can mention the version code as follows.
apt-get install php7.4-tidy
I was having the same trouble, and wrote up my solution here:
Installing Tidy 2.0 PHP extension on Ubuntu 10.10
http://web.onassar.com/blog/2010/11/16/installing-tidy-2-0-php-extension-on-ubuntu-10-10/
It works on newer versions of Ubuntu as well.
While it may not be the most direct route, it works well.
I hope it helps others.
Put that line in php.ini next to the other extension=...dll lines and make sure php_tidy.dll is in the directory configured in php.ini under extension_dir.
In ubuntu: you need to run the following command in terminal
sudo apt-get install php5-tidy
and the restart the server
sudo service apache2 restart.
For those who are having trouble enabling Tidy extension for PHP (using PHP handler for Apache server) on Windows (WAMP server), please note that you may be editing the wrong php.ini file. Assuming that WAMP server is installed in C:\wamp[ver]\ where [ver] is a variable version number.
File that you're probably editing:
C:\wamp[ver]\bin\php\php[ver]\php.ini
File that you must edit:
C:\wamp[ver]\bin\apache\apache[ver]\bin\php.ini
You also might want to make sure what's the correct php.ini file to edit by creating an info php file and add this code to it:
<?php phpinfo();
Then look for Loaded Configuration File string.
Finally make sure you uncomment this line within the correct php.ini file:
extension=tidy

can I easily recomplie PHP with all my current settings and enable SOAP with the new configuration?

I have PHP 5.1.6 running with a ton of mods and extensions enabled, is there a way to reconfigure the current settings as well as add SOAP to the mix?
Yeah; if you do php -i|grep 'Configure Command', that will show you the current build options for your recompile. Just add the option for SOAP to that.
If you have the source-code of that version of PHP (pretty old, but you surely can find it somewhere ; for instance : http://www.php.net/releases/#5.1.6 ), yes, you can :
use phpinfo() or php -i : in the output, there will be the "configure" line that was used to build your current version of PHP
go to the sources directory, and run that configure line, with all its options ; don't forget to add the --enable-soap (If I remember correctly), to add the new extension !
Then build as you'd always do (make, make install)
And voila ;-)
And when you have the new PHP executable and/or module, just keep using the same php.ini, so you don't have to reconfigure everything.
for CentsOS 5 (Linux) I just found that I could use yum install php-soap and then restart Apache
php -i|grep 'Configure Command'
does not seem to work anymore. You can do
php-config
depending on your Linus distro you might be lucky and find you can simply install php-soap through your package manager
yum install php-soap for CentOS, or apt-get install php-soap for Debian/Ubuntu etc

Categories