我有我的本地Apache 2.2.22服務器上運行完美的python CGI腳本。它輸出正確的結果等等。但是當我嘗試在虛擬主機上執行它時,出現錯誤500. 我真的不知道爲什麼它不起作用。Python CGI腳本 - 500錯誤
Apache的錯誤日誌是這樣的:
[Wed Jul 12 16:06:54 2013] [error] [client 89.223.235.12] Premature end of script headers: /home/u67442/rrrrr.com/cgi-bin/test.py
[Wed Jul 12 16:09:31 2013] [error] [client 89.223.235.12] Premature end of script headers: /home/u67442/rrrrr.com/cgi-bin/test.py
我已經嘗試了以下幾件事:
- 我一定要解釋器的路徑是正確的 -
#!/usr/local/bin/python
。另一個CGI腳本可以正常工作。 - 我已經將chmod 755設置爲該腳本。
- 我已經設置了UNIX格式的行尾字符。
- 我用正確的HTTP標頭:腳本的
print "Content-type:text/html\n\n"
輸出部分:
print "Content-type:text/html\n\n"
print "<html>"
print "<head>"
print "<title>Results</title>"
print "<head><h2 align=center>Results</h2></head>"
print "</head>"
print '<body bgcolor="#e8f3d8">'
print "<hr>"
print "<b>Result = %s </b>" % str(round(total_sum, 5))
print "</body>"
print "</html>"
搞笑的是具有相同路徑另一個非常類似的腳本,頭,EOL,輸出等完美的作品在本地服務器和虛擬主機上。奇怪的是,這個腳本在我的本地apache上工作正常,但在虛擬虛擬主機上它崩潰了500個內部服務器錯誤。我真的不知道該怎麼做。技術支持人員表示在我的腳本中存在問題。
只有一個想法 - 超時的輸出等待。我的腳本中的數據處理需要大約15-25秒。
什麼,你可以諮詢?