php_ob_gzhandler_check以及令人崩溃的错误
继续诡异的问题。今天在一台Ubuntu 8.10 Server版本上用这样的configure条件:
'./configure' \
'--with-mysql=/usr/local/mysql' \
'--with-apxs2=/usr/local/apache/bin/apxs' \
'--enable-mbstring' \
'--with-mcrypt' \
'--with-gd' \
'--with-jpeg-dir=/usr/local/' \
'--with-png-dir=/usr/lib' \
'--enable-exif'
第一个问题:
configure: error: libjpeg.(a|so) not found.
我以为是libjpeg没装,下好libjpeg-6b.tar.gz,这样装了:
tar -zxvf libjpeg-6b.tar.gz
cd libjpeg-6b
./configure
make
sudo make install
但是还是提示上面的错误。很迷惑,后来发现是/usr/lib下没有libjpeg的文件,正确的libjpeg安装应该这样子:
tar -zxvf libjpeg-6b.tar.gz
cd libjpeg-6b
./configure
make
# 这一步很重要!
sudo make install-lib
sudo make install
PHP的configure成功结束了,但是make编译PHP 5.2.8时出错:
/home/nocoo/soft/php-5.2.8/main/output.c:421:
undefined reference to `php_ob_gzhandler_check'
collect2: ld returned 1 exit status
make: *** Error 1
大惑不解,然后我搜我搜我搜搜搜,终于发现,只需要加入'--with-zlib'就可以让PHP用zlib,从而消除了这个配置错误。 最终正确的configure命令如下:
'./configure' \
'--with-mysql=/usr/local/mysql' \
'--with-apxs2=/usr/local/apache/bin/apxs' \
'--enable-mbstring' \
'--with-mcrypt' \
'--with-zlib' \
'--with-gd' \
'--with-jpeg-dir=/usr/local/' \
'--with-png-dir=/usr/lib' \
'--enable-exif'
为了达成这样一个PHP configure,当中我装过的lib列表如下:
- libxml2-sources-2.7.2.tar.gz
- zlib-1.2.3.tar.gz
- libmcrypt-2.5.8.tar.gz
- libpng-1.2.34.tar.gz
- libjpeg-6b.tar.gz
- gd-2.0.35.tar.gz
因为简单执行:
tar -zxvf {target}.tar.gz
cd {target}
./configure
make
sudo make install
就成功了,所以这里没什么好说的,你要是缺,也装上即可。