exec from php is causing an “Premature end of script headers: php-cgi.exe” error

前端 未结 2 576
借酒劲吻你
借酒劲吻你 2021-01-15 05:08

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

相关标签:
2条回答
  • 2021-01-15 05:35

    Apparently, the default httpd.conf file included in Apache 2.4 doesn't automatically include the extra file httpd-default.conf under /conf/extra (probably by design), which includes the timeout parameter. Since the timeout parameter isn't defined, it reverts back to the default value of 30 seconds, and your script(s) time out.

    I did the following to resolve it:

    • Opened httpd.conf and added the following line to the bottom:

    Include conf/extra/httpd-default.conf

    • Restarted Apache, and it worked.

    An alternative would be to simply add the following line(s) to the httpd.conf file:

    Timeout 300
    KeepAlive On
    MaxKeepAliveRequests 100
    KeepAliveTimeout 5

    Hope this helps someone out there :)

    0 讨论(0)
  • 2021-01-15 05:48

    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.

    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

    0 讨论(0)
提交回复
热议问题