CentOS单独编译安装PHP gd库扩展
注意:如果您已经编译安装过GD库,请重新编译安装php不带gd库成功后,执行以下操作
安装libpng
wget http://jaist.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.gz
tar -xf libpng-1.6.37.tar.gz
cd libpng-1.6.37
CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/libpng
make && make install
安装jpegsrc
wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz
tar -xf jpegsrc.v9a.tar.gz
cd jpeg-9a/
CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/jpeg
make && make install
mkdir -p /usr/local/jpeg/include mkdir -p /usr/local/jpeg/lib mkdir -p /usr/local/jpeg/bin mkdir -p /usr/local/jpeg/man/man1
安装freetype
wget http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.5.5.tar.gz
tar -xf freetype-2.5.5.tar.gz
cd freetype-2.5.5
./configure --prefix=/usr/local/freetype
make && make install
跳转到php源码GD目录
cd home/apps/web/php/php-5.6.2/ext/gd
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/
make
make install
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. 请安装re2c
这里出现了错误 Module 'gd' already loaded in Unknown on line 0 原因是编译安装的时候已经带上GD库,请重新编译安装不带上gd
php.ini 添加extension=gd.so
重启web服务器和php-fpm