今天在Linux底下編寫導出EXCEL文件並顯示輸出時,拋出“ZipArchive library is not enabled” 的異常。而我在本地的windows下的代碼則是運行正常的。
原因是:在Linux下沒有php_zip.dll這個文件(有也不會起作用的),所以需要重新編譯一下php的zip模塊。
在Unix/Linux下的解決辦法 :
wget http://pecl.php.net/get/zip tar zxvf zip cd zip-1.13.1/ locate phpize /usr/local/php/bin/phpize locate php-config ./configure --with-php-config=/usr/local/php/bin/php-config&&make&&make install
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
cd /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
ls
memcache.so opcache.so xcache.so zip.so
在php.ini 文件中添加:
extension_dir=/usr/local/php/lib/php/extensions/no-debug-zts-20131226/ [xcache-common] extension = xcache.so extension = memcache.so extension = zip.so
然后同樣在php.ini文件中,將zlib.output_compression = Off 改為 zlib.output_compression = On ;
重新啟動apache 或者nginx 查看。