Linux主机重编译PHP支持GD库

*注意:请确认以下您服务器中Apache的安装路径,如果不是 /usr/local/apache2,则在进行以下安装操作时, 注意修改Apache的安装路径!

1、以root身份登录Linux主机;

2、停止Web Server服务,如果使用的是Apache可以通过以下命令停止: shell> /usr/local/apache2/bin/apachectl stop

3、卸载当前PHP和Zend Optimizer: shell> rm -rf /usr/local/php shell> rm -rf /usr/local/Zend shell> vi /usr/local/apache2/conf/httpd.conf 找到LoadModule phpX_module modules/libphpX.so 其中X是PHP版本(4或者5)一行,并将此行删除,保存退出。

4、下载安装Discuz! GD库安装包: shell> cd /usr/local/src shell> wget -c http://download.discuz.net/gdinstaller.tar.gz shell> tar xzvf gdinstaller.tar.gz shell> cd GDInstaller shell> ./install.sh

4、下载PHP 5.1.2: shell> cd /usr/local/src shell> wget -c http://download.discuz.net/php-5.1.2.tar.bz2

5、解压缩并安装PHP 5.1.2: shell> tar xjvf php-5.1.2.tar.bz2 shell> cd php-5.1.2 shell> ./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs
–with-zlib-dir –with-bz2 –with-tiff-dir –with-libxml-dir –with-gd –with-freetype-dir
–with-jpeg-dir –with-png-dir –with-ttf –enable-mbstring –with-mysql
–with-config-file-path=/etc –disable-ipv6 –enable-gd-native-ttf *注意:如果MySQL不是以RPM包方式安装的,则需要将上述参数中的–with-mysql 改为–with-mysql=/usr/local/mysql shell> make shell> make install shell> cp php.ini-dist /etc/php.ini

6、下载Zend Optimizer 2.6.2: shell> cd /usr/local/src sehll> wget -c http://download.discuz.net/ZendO … glibc21-i386.tar.gz

7、解压并安装Zend Optimizer 2.6.2: shell> tar xzvf ZendOptimizer-2.6.2-linux-glibc21-i386.tar.gz shell> cd ZendOptimizer-2.6.2-linux-glibc21-i386 shell> ./install.sh *注意:安装Zend过程中提示输入php.ini位置时,请填写/etc

安装并重新启动Apache服务后,可以创建phpinfo.php文件检查GD库的支持情况。