今天在用WordPress做的网站安装NextGen Cooliris Gallery插件过程中,提示出错:”Abort class-pclzip.php : Missing zlib extensions”.

Abort class-pclzip.php :Missing zlib extensions

很明显,PHP缺少了zlib扩展.VPS上的PHP版本是5.4.12,当时是编译安装的,只要重新编译下PHP就能解决.

先查一下关于zlib的参数是什么.


1
2
3
4
5
6
7
8
9
[deloz@deloz.net ~]# cd php-5.4.12[deloz@deloz.net php-5.4.12]# ./configure --help | grep zlib--with-zlib=DIR       Include ZLIB support (requires zlib >= 1.0.9)--with-zlib-dir=<DIR>   Define the location of zlib install directory
  --with-zlib-dir=DIR     GD: Set the path to libz install prefix
  --with-zlib-dir=DIR     MySQL: Set the path to libz install prefix
  --with-zlib-dir=DIR       PDO_MySQL: Set the path to libz install prefix
  --with-zlib-dir=DIR     ZIP: Set the path to libz install prefix
  --with-zlib-dir=DIR       mysqlnd: Set the path to libz install prefix


这些多条结果,都是相同的-with-zlib-dir,那就用这个吧.具体的用途可以看看.

除了-with-zlib-dir还不行,当时编译时用了一大串的…可惜我不记得了…不过还好,想到了phpinfo()这个显示PHP配置信息的函数.输出看看Configure Command项的值.

phpinfo-ConfigureCommand

还行,大部分常用的都有.去除单引号,在后面加上-with-zlib-dir, 然后编译….


1
2
3
[deloz@deloz.net php-5.4.12]# make clean[deloz@deloz.net php-5.4.12]# ./configure --enable-pdo --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-iconv --with-gd --with-jpeg-dir=/usr/local/lib --enable-mbstring --with-curl --with-mcrypt --with-zip --with-png-dir=/usr/local/lib --enable-gd-native-ttf --with-gettext --with-pear --enable-exif --enable-fpm --enable-fastcgi -with-zlib-dir=/usr/lib/php/modules/[deloz@deloz.net php-5.4.12]# make && make install


重启一下php-fpm,再看看phpinfo()的输出有zlib了…

phpinfo输出有zlib了

打开WordPress后台,再试安装NextGen Cooliris Gallery,终于正常了.最后把phpinfo函数删除.

NextGEN Gallery插件安装成功