close
最近有一個客戶要用最土網的團購模版,
在本伺服器運作的時候常常出現CGI Error,主要訊息如下:
The specified CGI application misbehaved by not returning a complete set of HTTP headers

此後網頁就無法顯示了。

查了一下網路,對此有幾種解決法,但是不是能針對正確的問題,我倒是沒試過。
主要是把自己找過的記錄下來,以便日後自己與他人能參考。

php.net官網的說明與解釋:
主要是說在php與mysql因在IIS下執行所造成重新導向不成功,若使用Apache 沒有此問題。
https://bugs.php.net/bug.php?id=25863
===============================================================

以下是第一種官方的解法(沒真的試過,我有更簡單的方法):
I followed all the hints here but IIS 5 and PHP 5 would still not behave.
What was necessary in the end was:
1) Set [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Script Map] ".php"="your path to php\\php.exe"
2) ensure there is not a php.ini in the windows system folder and that there is one wherever you've put PHP
3) edit php.ini and set cgi force redirect to 0 and cgi.rfc2616_headers = 1
4) Put the PHP scripts in their own folder underneath the inetpub root
5) Open the IIS console, right click your new php folder
In the Directory tab set application name to the name of the folder
set executable and script as permission
set application protection to low
Click configuration and check that .php is mapped to wherever you put PHP
Restart IIS
--------------------------------------------------------------------
以下是第二種他人的解法(沒試過,應該不是主要的問題):
應該指 CGI Header output 不正確,所呈現的錯誤訊息.

解決方法:將你的 CGI Source Code 的 Header Output 加上如下兩行,再 Compiler 看看
(PS.我找了整個資料匣,也沒看到半個.cgi的檔案)
 print "HTTP/1.0 200 OK\n";
print "Content-Type: text/html\n\n\n";
--------------------------------------------------------------------
 
以下是第三種他人的說明(沒試過,有機會可以修正成功,跟官方說法相似):
意思是:(http協議的CGI模式運行不正確)

因為perl腳本的第一句中不支持 -wT 參數,將所有的 -wT 替換成 -w 即可
即:將 #!/usr/bin/perl –wT 替換為:將 #!/usr/bin/perl –w
這是代表php是以CGI模試運行的 在php.ini找到 gi.force_redirect 把前面的分號去掉 把值改成0就行了。

再次運行就可以了,這是PHP另一種運行模式的配置方法
--------------------------------------------------------------------
本人的做法:
很簡單,把原本php執行的腳本從標準CGI改成FastCGI就可以了。
arrow
arrow
    全站熱搜

    NetPC虛擬主機 發表在 痞客邦 留言(0) 人氣()