apt-get安装的php默认就自带了zlib了吧:php-m|grepzlib查看zlib是否已经加载php--ini查看当前使用的配置文件(没有配置文件,PHP也是能正常工作的)其实这些在phpinfo里都能看到的吧.今天关机了,明天一早把phpinfo发给你老看一下
@eechen这里是phar的信息
PharPhar:PHPArchivesupportenabledPharEXTversion2.0.1PharAPIversion1.1.1SVNrevision$Id:ec823514107160b7e6fabc519594012657a2db91$Phar-basedphararchivesenabledTar-basedphararchivesenabledZIP-basedphararchivesenabledgzipcompressiondisabled(installext/zlib)bzip2compressiondisabled(installpecl/bz2)OpenSSLsupportdisabled(installext/openssl)
sudoapt-getinstallphp5-cli
/usr/bin/php5-r'print_r(get_declared_classes());'|grepZipArchive
[122]=>ZipArchive
我这边是能找到这个已经声明的类的.
好我试试,刚才我扯了一下可能是和配置路径损坏有关系,我默认安装ubuntu的apt-get了5.3,后来手工升级成5.4这下子好像就乱了.我看到ConfigurationFile(php.ini)Path这类变量和实际的并不相同无语啊
已经找到原因了,还是升级编译php出的纰漏,
这些选项不是默认的,真恶心啊...
重新编译加上去安装之后就没问题了感谢@eechen回复@eechen:是的,我以为很多选项都是默认的...杯具了http://php.net/manual/en/zip.installation.php你应该是在configure时漏了--enable-zip,所以没有ZipArchive这个类.https://wiki.php.net/phpng
这是鸟哥他们开发测试用的编译配置,覆盖了大多数常用的功能,你参考一下:
./configure
--prefix=$HOME/tmp/usr
--with-config-file-path=$HOME/tmp/usr/etc
--enable-mbstring
--enable-zip
--enable-bcmath
--enable-pcntl
--enable-ftp
--enable-exif
--enable-calendar
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm
--enable-wddx
--with-curl
--with-mcrypt
--with-iconv
--with-gmp
--with-pspell
--with-gd
--with-jpeg-dir=/usr
--with-png-dir=/usr
--with-zlib-dir=/usr
--with-xpm-dir=/usr
--with-freetype-dir=/usr
--with-t1lib=/usr
--enable-gd-native-ttf
--enable-gd-jis-conv
--with-openssl
--with-mysql=/usr
--with-pdo-mysql=/usr
--with-gettext=/usr
--with-zlib=/usr
--with-bz2=/usr
--with-recode=/usr
--with-mysqli=/usr/bin/mysql_config
根据https://wiki.php.net/phpng总结得出的新的编译参数:
sudoapt-getinstall
build-essential
autoconf
libtool
re2c
libxml2-dev
openssl
libcurl4-openssl-dev
libbz2-dev
libjpeg-dev
libpng12-dev
libfreetype6-dev
libldap2-dev
libmcrypt-dev
libmysqlclient-dev
libxslt1-dev
libxt-dev
libpcre3-dev
libxpm-dev
libt1-dev
libgmp-dev
libpspell-dev
librecode-dev
libxml2-dev依赖libxml2,安装开发包libxml2-dev时会自动安装上共享库libxml2,其他开发包也类似.
sudoln-s/usr/include/x86_64-linux-gnu/gmp.h/usr/include/gmp.h或者--with-gmp=/usr/include/x86_64-linux-gnu
./configure
--prefix=/png/php/phpng
--enable-fpm
--enable-opcache
--enable-pdo
--enable-sockets
--enable-exif
--enable-soap
--enable-ftp
--enable-wddx
--enable-pcntl
--enable-soap
--enable-bcmath
--enable-mbstring
--enable-dba
--enable-gd-native-ttf
--enable-gd-jis-conv
--enable-zip
--enable-calendar
--enable-shmop
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm
--with-mysql
--with-mysqli
--with-pdo-mysql
--with-pdo-sqlite
--with-iconv
--with-gmp
--with-pspell
--with-gettext
--with-xmlrpc
--with-openssl
--with-mhash
--with-mcrypt
--with-xsl
--with-curl
--with-pcre-regex
--with-gd
--with-jpeg-dir=/usr
--with-png-dir=/usr
--with-zlib-dir=/usr
--with-xpm-dir=/usr
--with-freetype-dir=/usr
--with-t1lib=/usr
--with-gettext=/usr
--with-zlib=/usr
--with-bz2=/usr
--with-recode=/usr
--with-ldap
--with-pear
--with-fpm-user=png
--with-fpm-group=png
--with-apxs2=/png/httpd/2.4.10/bin/apxs感谢!