2010-12-02 78 views
22

我有一个基于CodeIgniter的基于solr索引服务器的php网站。500服务器错误:脚本标题提前结束:

我们得到了很多新的内容,所以我们刷新了数据库,并且不得不重新索引内容(约168,000个元素)。我创建了一个脚本,通过500个切片索引内容 - 当脚本结束时,我们启动下一个索引。

它完全在我的本地测试环境,但对生产我得到这个500错误:

[Thu Dec 02 ...] [error] [client IP] Premature end of script headers: index.php 

绝对没有在我的php.log,只是在Apache的error_log返回它。我曾在网站的其他页面上看到过这种情况,但这是在此索引过程中发生的。

任何想法?

+1

没有足够的信息来告诉。如果它在你的测试环境中工作,我会怀疑文件许可:是以不同用户身份运行的apache服务器? – 2010-12-02 15:48:31

+0

因此,让脚本在每几行之后写入日志信息,以便您知道它究竟在哪里断开。 – 2010-12-02 15:57:55

+0

Colin Fine:我不认为它来自用户,我使用suphp运行php,每个服务器都是分隔的 WhatIsOpenID:不是它不是500个不同的错误,它是apache返回一个“500内部服务器错误”代码 – 2010-12-03 10:10:03

回答

0

你在php中的error_level是什么?您在日志中获得的错误消息通常是由于一个简单的PHP错误导致的,但是由于安全原因,服务器设置为不向客户端传递错误消息。通过这个消息不是很有帮助,它可能是一切。

24

此错误通常(有时)是由于FcgidIOTimeout directive(旧名称:IPCCommTimeout)的FastCGI设置引起的。

这是IO超时的秒数,默认为40秒。超时意味着

"The FastCGI application must begin generating the response within this period of time. Increase this directive as necessary to handle applications which take a relatively long period of time to respond."

你可以尝试去解决它投入您的vhost.conf这样的:

<IfModule mod_fcgid.c> 
    # 5 minutes for IO timeout, default is 40 seconds 
    FcgidIOTimeout 300 
</IfModule> 

你可以增加它,你需要再恢复原值一次重新索引过程完成。

4

在Liquid Web的KB上有很多可能的清单,

  1. Upgrading or downgrading to a different version of PHP can leave residual options in the httpd.conf. Check the current version of PHP using php -v on the command line and search for any lines mentioning another version in the httpd.conf. If you find them, comment them out, distill the httpd.conf and restart apache.

  2. The RLimitCPU and RLimitMEM directives in the httpd.conf may also be responsible for the error if a script was killed due to a resource limit.

  3. A configuration problem in suEXEC, mod_perl, or another third party module can often interfere with the execution of scripts and cause the error. If these are the cause, additional information relating to specifics will be found in the apache error_log.

  4. If suphp’s log reaches 2GB in size or larger you may see the premature end of scripts headers error. See what the log contains and either gzip it or null it. Restart apache and then deal with any issues that the suphp log brought to light. The suphp log is located at: /usr/local/apache/logs/suphp_log

  5. The script’s permissions may also cause this error. CGI scripts can only access resources allowed for the User and Group specified in the httpd.conf. In this case, the error may simply be pointing out that an unauthorized user is attempting to access a script.

http://www.liquidweb.com/kb/apache-error-premature-end-of-script-headers/

如果我是在同样的情况,我会检查权限第一,然后用3和4

-3

ü忘了补充内容类型头中的响应继续其在apache2上托管时必须有http头

header('Content-Type: text/html'); 
1

它也可以因为使用PHP APC Extension而出错。 所以首先从php.ini中删除apc.so重新启动apache,然后再次测试:)

2

我也在接收到这个错误消息在etc/httpd/logs/error_log后500尝试加载一个网站的内部服务器错误。

对我来说,解决方案是权限 - 必须chmod 755文件。我将该文件创建为比在服务器上“加载”该站点的用户更高的访问级别用户。

0

我有这个问题,经过5个多小时的努力,我禁用了xcache,一切恢复正常,错误消失了!

-5

我有同样的问题,只需重新启动Apache服务器,它的工作