私は Perl の世界に属していないので、これのいくつかは私にとって初めてのことです。apache2 および mod_fcgid パッケージがインストールされた Ubuntu Hardy LTS を実行しています。mod-cgi ではなく fcgid で MT4 を実行したいと考えています (従来の CGI で問題なく動作するようです)。
単純な Perl スクリプトを fcgid の下で実行することすらできないようです。シンプルな「Hello World」アプリを作成し、この前の質問のコードを含めて、 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";
}
コマンド ラインから実行すると、"plain old Boring..." が出力されます。Apache への http 要求を介して呼び出すと、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 構成に加えて、VirtualHost ディレクティブにあります。
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>