php中Fatal error: Class ZipArchive not found的解决办法
出现这个错误说明是程序在调用'ZipArchive' 这个类的时候没有成功,原因是由于在安装php的时候没有增加php zip的支持(非zlib)。
在Windows下的解决办法是:
1、在php.ini文件中,将extension=php_zip.dll前面的分号“;”去除,然后同样在php.ini文件中,将 zlib.output_compression = Off 改为 zlib.output_compression = On ;
2、重启Apache服务器。
在Unix/Linux下的解决办法:
1、在Linux下没有php_zip.dll这个文件(有也不会起作用的),所以需要重新编译一下php的zip模块。具体安装方法如下:
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy2020')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy2020>cd /usr/src
wget http://pecl.php.net/get/zip
tar -zxvf zip
cd zip-1.x.x
phpize
./configure
make
sudo make instal
其中, 在最后使用make install命令的时候,可能需要用到root的权限,所以建议使用sudo来运行。安装完之后,屏幕上会提示zip.so的位置。然后将其记录下来,如:/usr/local/lib/php/extensions/zip.so。
2、使用root权限修改php.ini(通常可能会在/usr/local/lib/文件夹下,不过视当初安装php而定,可以通过phpinfo()来查看):
增加
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy4686')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy4686>extension = /usr/local/lib/php/extensions/zip.so,然后同样在php.ini文件中,将
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6981')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6981>zlib.output_compression = Off改为
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6261')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6261>zlib.output_compression = On ;3、最后别忘了重启一下Apache:apachectl restart;
这个针对php的zip模块就安装完成了,能够在php中使用ZipArchive类了
您可能感兴趣的文章:
php使用ZipArchive提示Fatal error: Class ZipArchive not found in
php中Fatal error: Class ZipArchive not found的解决办法
PHP 报错 Fatal error: Class 'COM' not found in 的解决方法
安装MYSQL-PYTHON包报错mysql_config not found解决办法
解决PHP报错ZipArchive library is not enabled异常的方法
Fatal error: Maximum execution time of 30 错误解决办法
PHP5.3提示Fatal error: Undefined class constant MYSQL_ATTR_INIT_COMMAND
php ZipArchive类使用实例详解
编译错误“fatal error: 'xxxx.h' file not found” 如何解决
php include提示failed to open stream: Permission denied in错误