Home > Article > Backend Development > How to enable GD library support in PHP
How to enable GD library support in PHP
Enable PHP's GD library support under Linux
#There are several ways to enable GD library support
##Detect whether the GD library is installed using the command
php5 -m | grep -i gd
or
php -i | grep -i --color gd
##If the GD library is not installed, install it on the server. The method is as follows
### If it is a source code installation, add the parameters
--with-gd
### If it is For debian-based Linux systems, use apt-get to install it, as follows
apt-get install php5-gd
### If it is a CentOS system, use yum to install it, as follows
yum install php-gd
### If it is suse System Linux system, use yast to install it, as follows
yast -i php5_gd
### If you think this world is not painful enough, you can add it when the original compiled PHP does not support GD
First download the zlib source code, libpng source code, gd Source code
Unzip to the source code directory
zlib directory
./configure --prefix=/usr/local/zlib
make ; make install
make clean
libpng directory
cp scripts/makefile.linux ./makefile
./configure - -prefix=/usr/local/libpng
make ; make install
make clean
gd directory
./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng
make ; make install
make clean
Finally, in php.ini, after searching for [gd], add a line below
extension=/usr/local/libgdgd.so
Then restart the php service. If it doesn’t work, try reboot
Okay, But a final reminder, you must know that there are many surprises in this world. In the case of source code installation and only adding the gd library, the PHP version and the library version are different, so:
- There is no guarantee that there will be returns after so much effort
- There is no guarantee that gd.so can be loaded successfully
- There is no guarantee that you will not get pregnant
So if it is a source code installation, it is best to add the parameter --with-gd when compiling PHP
Enable PHP's GD library support under Windows
Find php.ini , open the content and find:
;extension=php_gd2.dll
Remove the semicolon ";" at the front and save it. If there is no semicolon in the first place, it means it has been turned on.
The above introduces how to enable GD library support in PHP, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.