我不屬於Perl世界,所以這對我來說是新的。我正在運行安裝了apache2和mod_fcgid軟件包的Ubuntu Hardy LTS。我想讓MT4在fcgid下運行,而不是mod-cgi(它對普通的CGI似乎運行良好)。爲什麼我的簡單fastCGI Perl腳本失敗?
我似乎無法得到一個簡單的Perl腳本來運行在fcgid下。我創建了一個簡單的「Hello World」應用程序,幷包含來自this previous question的代碼以測試FCGI是否正在運行。
我將我的腳本命名爲HelloWorld.fcgi(當前fcgid僅設置爲處理.fcgi文件)。代碼:
#!/usr/bin/perl
use FCGI;
print "Content-type: text/html\n\n";
print "Hello world.\n\n";
my $request = FCGI::Request();
if ($request->IsFastCGI) {
print "we're running under FastCGI!\n";
} else {
print "plain old boring CGI\n";
}
當在命令行中運行,它打印「普通老式無聊......」當通過HTTP請求來調用apache的,我得到一個500內部服務器錯誤和腳本的輸出打印到Apache錯誤日誌:
Content-type: text/html
Hello world.
we're running under FastCGI!
[Wed Dec 03 22:26:19 2008] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Dec 03 22:26:19 2008] [error] [client 70.23.221.171] Premature end of script headers: HelloWorld.fcgi
[Wed Dec 03 22:26:25 2008] [notice] mod_fcgid: process /www/mt/HelloWorld.fcgi(14189) exit(communication error), terminated by calling exit(), return code: 0
當我運行相同代碼的.cgi版本時,它工作正常。任何想法爲什麼腳本的輸出是去錯誤日誌? Apache配置是默認配置mod_fcgid加,在虛擬主機的指令:
ServerName test1.example.com
DocumentRoot /www/example
<Directory /www/example>
AllowOverride None
AddHandler cgi-script .cgi
AddHandler fcgid-script .fcgi
Options +ExecCGI +Includes +FollowSymLinks
</Directory>
試過了,結果相似。還嘗試使用簡單的CGI :: Fast Hello World - 也失敗了。很奇怪... – sstrudeau 2008-12-04 18:06:53