Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Apache切换到Nginx:PHPExcel不再工作_Apache_Nginx_Phpexcel - Fatal编程技术网

从Apache切换到Nginx:PHPExcel不再工作

从Apache切换到Nginx:PHPExcel不再工作,apache,nginx,phpexcel,Apache,Nginx,Phpexcel,我在Apache2.2上,在我的应用程序的某个地方,我正在用PHPExcel生成Excel文档。它工作得很好 我切换到Nginx/php5 fpm,从那以后生成的文件就不可读了。我尝试删除nginx vhost/conf下的所有优化 Apache响应头可读excel文件: Cache-Control:no-cache Connection:close Content-Disposition:attachment; filename="Export-3339-Lettre d'actualité

我在Apache2.2上,在我的应用程序的某个地方,我正在用PHPExcel生成Excel文档。它工作得很好

我切换到Nginx/php5 fpm,从那以后生成的文件就不可读了。我尝试删除nginx vhost/conf下的所有优化

Apache响应头可读excel文件:

Cache-Control:no-cache
Connection:close
Content-Disposition:attachment; filename="Export-3339-Lettre d'actualité clients.xls"
Content-Type:application/vnd.ms-excel
Date:Mon, 22 Sep 2014 12:24:35 GMT
Server:Apache/2.2.26 (Unix) DAV/2 PHP/5.5.16 mod_ssl/2.2.26 OpenSSL/0.9.8y
X-Powered-By:PHP/5.5.16
Nginx响应头凌乱文件:

Cache-Control:no-cache
Connection:keep-alive
Content-Disposition:attachment; filename="Export-3339-Lettre d'actualité clients.xls"
Content-Type:application/vnd.ms-excel
Date:Mon, 22 Sep 2014 12:22:02 GMT
Server:nginx
Transfer-Encoding:chunked
X-Powered-By:PHP/5.5.9-1ubuntu4.4
该文件看起来像:

*编辑**关闭分块传输编码后,这里是响应头,但仍然没有有效的生成文档

Cache-Control:no-cache
Connection:close
Content-Disposition:attachment; filename="Export-3339-Lettre d'actualit%C3%A9 clients.xls"
Content-Type:application/vnd.ms-excel
Date:Wed, 24 Sep 2014 09:53:34 GMT
Server:nginx
X-Powered-By:PHP/5.5.9-1ubuntu4.4

找到解决方案后,它将改变响应的生成和返回方式


file\u get\u content而不是readfile修复了它。

明显的区别在于KeepAlive连接。你试过不用KeepAlive吗?嗯,还有分块编码。不知道为什么这个应用程序对它很敏感,但调查一下。似乎我无法在nginx中关闭KeepAlive而不修补核心:/我会先尝试一下:关闭它没有什么区别,我已经更新了我的问题来反映它。好吧,我脑海中剩下两个选项:字符集和压缩。这两个服务器都不发送字符集,因此php脚本不太可能但可能需要nginx配置中缺少的某些设置。压缩的可能性更大。您是否可能正在发送gzip压缩文件?如果这些都不成功,如果是最新的Excel格式,那么它只是压缩的XML文档,因此您可能会发现其中的一些差异,这提供了一个关于发生了什么的提示。