来自php的exec导致“脚本头过早结束:php-cgi.exe".错误 [英] exec from php is causing an "Premature end of script headers: php-cgi.exe" error

查看:63
本文介绍了来自php的exec导致“脚本头过早结束:php-cgi.exe".错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个php脚本,该脚本使用exec调用外部命令,该命令将空间数据库查询结果编译为shape文件.在具有大量记录(例如15,000)的表中,此命令可能需要长达7分钟的时间才能执行.该脚本在不会花费太长时间(可能小于2分钟)的脚本上运行良好,但是在较长的脚本(例如7分钟的脚本)上,该页面将显示"500内部服务器错误".查看Apache服务器日志后,错误指出:脚本头过早结束:php-cgi.exe".我已经调整了php的最大执行时间,以允许有足够的时间,所以我知道不是这样.是否有Apache最大值被击中,或者其他原因?

I have a php script written which calls an external command using exec which compiles a spacial database query result into a shape file. In tables with lots of records (say 15,000), this command can take as long as 7 minutes to execute. The script works fine on scripts which do not take too long (maybe <2min) but on longer scripts (like the 7 minute one) the page will display "500 internal server error". Upon reviewing the Apache server log, the error states: "Premature end of script headers: php-cgi.exe". I have already adjusted the php maximum execution time to allow more than enough time, so I know it is not this. Is there an Apache maximum that's being hit, or something else?

推荐答案

脚本头过早结束意味着您的脚本超出了Web服务器CGI脚本的超时时间.这是Web服务器超时,与php.ini配置无关.您需要查看CGI处理程序配置,以增加CGI脚本运行所需的时间.

Premature end of script headers means that webserver's timeout for CGI scripts was exceeded by your script. This is a webserver timeout and it has nothing to do with php.ini configuration. You need to look at your CGI handler configuration to increase time allowed for CGI scripts to run.

例如如果您使用的是mod_fastcgi,则可能需要在Apache配置中指定以下选项:FastCgiServer -idle-timeout 600,这将使您超时10分钟.默认情况下,fastcgi提供30秒.您可以在 http://www.fastcgi.com/mod_fastcgi/docs中找到其他一些fastcgi选项. /mod_fastcgi.html

E.g. if you are using mod_fastcgi you may want to specify the following option in your Apache config: FastCgiServer -idle-timeout 600 which will give you timeout of 10 minutes. By default fastcgi provides 30 seconds. You could find some other fastcgi options here http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html

这篇关于来自php的exec导致“脚本头过早结束:php-cgi.exe".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆