wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/gd-2.0.33.tar.gz
tar -zxf gd-2.0.33.tar.gz
cd gd-2.0.33
mkdir -p /usr/local/gd2
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg/ --with-png=/usr/local/libpng/ --with-zlib=/usr/local/zlib/ --with-freetype=/usr/local/freetype/
make
make install(如果出错见下文)
6、集成PHP GD扩展 到PHP里
切换到PHP源码包
如果已经安装php,建议通过追加编译安装
进入“[php解压目录]/ext/gd”目录,执行如下命令:
[php安装目录]/bin/phpize
Java代码
./configure --with-php-config=[php安装目录]/bin/php-config --with-jpeg=[jpeg-6b安装目录] --with-png=[libpng安装目录] --with-freetype=[freetype安装目录] --with-zlib=[zlib安装目录] --with-gd=[gd安装目录]
(如果出现未知配置项--with-png**,--with-freetype之类的错误 在配置项后面加上-dir参数即可:既修编译参数为: ./configure --with-php-config=[php安装目录]/bin/php-config --with-jpeg-dir=[jpeg安装目录] --with-png-dir=[libpng安装目录] --with-freetype-dir=[freetype安装目录] --with-zlib=[zlib安装目录] --with-gd=[gd安装目录] 即可
)
make
make install
安装成功后会在“[php安装目录]/lib/php/extensions/no-debug-non-zts-20060613”目录下生成gd.so文件,
然后cp [php安装目录]/lib/php/extensions/no-debug-non-zts-20060613/gd.so /opt/php/ext
修改php.ini文件加载gd组件,添加extension_dir=/opt/php/ext和extension=gd.so,如果有extension_dir=/opt/php/ext则不需要增加
Java代码
extension_dir=/opt/php/ext
extension=gd.so
./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 --with-zlib-dir=/usr/local/zlib --with-gd=/usr/local/gd2
执行编译安装
make
make install
具体操作流程如下:
$ cd <php源码>/ext/gd
$ /usr/local/php5/bin/phpize
$ ./configure --with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --with-zlib-dir=/usr/local/zlib --with-php-config=/usr/local/php/bin/php-config
$ make && make install
修改php.ini
$ make && make install
添加extension=gd.so
最后,重启apache