一,直接安装
yum install php-gd
二,不重新编译php,添加gd扩展
1、先编译安装好gd库
http://google-desktop-for-linux-mirror.googlecode.com/files/gd-2.0.35.tar.gz
cd /usr/local/src
tar -zxvf gd-2.0.35.tar.gz
mkdir -p /usr/local/gd
cd gd-2.0.35
./configure --prefix=/usr/local/gd --enable-m4_pattern_allow --with-jpeg=/usr/local/jpeg9 --with-png --with-zlib --with-freetype=/usr/local/freetype--with-libmcrypt=/usr/local/libmcrypt
make
make install
2、进入“[php解压目录]/ext/gd”目录,进行扩展添加
执行下面命令:
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config -with-jpeg=/usr/local/jpeg9 --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-zlib=/usr/local/zlib --with-gd=/usr/local/gd
make 时候,
/usr/include/ft2build.h:56:38: error: freetype/config/ftheader.h: No such file or directory
/usr/local/src/php-5.3.28/ext/gd/gd.c:83:12: error: #include expects “FILENAME” or
make: *** [gd.lo] Error 1
解决办法:
ln -s /usr/include/freetype2/freetype/ /usr/include/freetype
问题解决,继续安装:
[root@AY140404104215567249Z gd]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
Installing header files: /usr/local/php/include/php/
成功添加扩展。