解决Linux下phpexcel无法导出问题
问题描述:用phpexcel导出,提示连接失败,错误代码:err_invalid_response;同样代码,windows服务器上可以正常导出。
问题原因:缺少php_zip
可阅读phpexcel文件中的install.txt
Requirements
The following requirements should be met prior to using PHPExcel:
- PHP version 5.2.0 or higher
- PHP extension php_zip enabled *)
- PHP extension php_xml enabled
- PHP extension php_gd2 enabled (if not compiled in)
*) php_zip is only needed by PHPExcel_Reader_Excel2007, PHPExcel_Writer_Excel2007,
PHPExcel_Reader_OOCalc. In other words, if you need PHPExcel to handle .xlsx or .ods
files you will need the zip extension, but otherwise not.
解决办法:
1、依次运行以下命令:
wget http://pecl.php.net/get/zip-1.12.4.tgz //貌似已经出新版本了zip1.10.2.tgz
tar zxvf zip-1.12.4.tgz
cd zip-1.12.4
/usr/local/php/bin/phpize (对应的phpize路径)(安装好的php位置)
./configure --with-php-config=/usr/local/php/bin/php-config (对应的php-config路径)(php-config文件名不能更改)
make
make test
make install
//此时会在zip/modules/下生成一个zip.so文件,将它拷贝到make之后给的一个路径下,如有同名的,覆盖之。
2、生成的模块路径:
/usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/zip.so (对应的extensions路径)
3、修改php.ini
找的extension_dir
将前面生成的zip.so文件放到extension_dir对应的目录下
在extension_dir下面增加extension=zip.so
保存php.ini
4、重启apache
apache2/bin/apachectl restart
问题解决。
参考资料:
http://macleo.iteye.com/blog/1433000
http://blog.csdn.net/binger819623/article/details/6228968
http://yang2001.blog.51cto.com/25307/212322
http://hi.baidu.com/ubuntu2me/blog/item/c41a0211920464f0c3ce79d1.html
// ob_end_clean();