解决PHP报错ZipArchive library is not enabled异常的方法
今天在Linux底下上传Excel文件时,抛出“ZipArchive library is not enabled” 的异常。而我在本地的windows下的代码则是运行正常的。
原因是:在Linux下没有php_zip.dll这个文件(有也不会起作用的),所以需要重新编译一下php的zip模块。
在Unix/Linux下的解决办法 :
1、依次运行如下命令:
2、查看生成的模块路径(安装完之后,屏幕上会提示zip.so的位置):
cd /usr/lib/php/modules/ (对应的extensions路径 /usr/lib/php/modules/)
3、修改php.ini
增加 extension=zip.so
然后同样在php.ini文件中,将zlib.output_compression = Off 改为 zlib.output_compression = On ;
4、最后再重启一下Apache:./apachectl restart ;
这个针对php的zip模块就安装完成了,能够在php中使用ZipArchive类了。
附:在Windows下的解决办法就比较简单了 :
1、在php.ini文件中,将extension=php_zip.dll前面的分号“;”去除
然后同样在php.ini文件中,将 zlib.output_compression = Off 改为 zlib.output_compression = On ;
2、重启Apache服务器。
您可能感兴趣的文章:
解决PHP报错ZipArchive library is not enabled异常的方法
Eclipse错误:Selected SVN connector library is not available or cannot be loaded
php使用ZipArchive提示Fatal error: Class ZipArchive not found in
PHP Parse Error: syntax error, unexpected $end 错误解决办法
php中Fatal error: Class ZipArchive not found的解决办法
php 启动时报错的解决方法
php ZipArchive类使用实例详解
php利用ZipArchive类实现文件压缩与解压
解决jquery submit()提交表单提示:f[s] is not a function
php ZipArchive压缩函数的例子