GD库默认不安装JPEG扩展
安装JPEG
cd /usr/local/src
tar -xvf jpegsrc.v9a.tar.gz
cd jpeg-9a
./configure --prefix=/usr/local/jpeg --enable-shared
make
make install
安装好的文件存放在 /usr/local/jpeg/lib下
重新编译php
cd /usr/local/src/php-5.5.34
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-pear --with-gettext --enable-session --with-mcrypt --with-curl --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/include/freetype2/freetype --enable-gd-native-ttf
make
make install
进入php安装包对应的gd扩展里面进行重新编译
cd /usr/local/src/php-5.5.34/ext/gd/
/usr/local/php5/bin/phpize
./configure --with-php-config=/usr/local/php5/bin/php-config --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/include/freetype2/freetype/ --enable-gd-native-ttf
make && make install
会生成如下内容
Libraries have been installed in:
/usr/local/src/php-5.5.34/ext/gd/modules
Installing shared extensions: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/
Installing header files: /usr/local/php5/include/php/
为了方便,把.so文件集中放置
mv /usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/gd.so /usr/local/php5/lib/php/extensions/
修改php.ini文件
找到 ;extension_dir = “./”这一行,去掉注释,并修改路径。
extension_dir = "/usr/local/php5/lib/php/extensions/"
extension=gd.so
重启php服务器
service php-fpm reload