2010-12-02 60 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服務器,它的工作

相關問題