Movable Type3.35をFast CGIで動かす(on FedoraCore6 with Apache2)

基本はyumでmod_fcgidをインストールしただけ。

# yum install mod_fcgid
# /sbin/service httpd reload

そうすると、/etc/httpd/conf.d/fcgid.conf というのが勝手にできる。Fedoraの標準的なhttpd.conf 使っていれば、conf.d 以下の*.confファイルは勝手に読み込まれる。

内容はこんな感じ。

# This is the Apache server configuration file for providing FastCGI support
# through mod_fcgid
#
# Documentation is available at http://fastcgi.coremail.cn/doc.htm

LoadModule fcgid_module modules/mod_fcgid.so

# Use FastCGI to process .fcg .fcgi & .fpl scripts
# Don't do this if mod_fastcgi is present, as it will try to do the same thing
<IfModule !mod_fastcgi.c>
    AddHandler fcgid-script fcg fcgi fpl
</IfModule>

# Sane place to put sockets and shared memory file
SocketPath run/mod_fcgid
SharememPath run/fcgid_shm

この辺ググると、なぜかFedoraの標準パッケージを使っていないで、どっかからバイナリ引っ張ってきたり、ソースからコンパイルしている人が多いのはなぜだろう。Apachなんか、そのまま使っても何の不自由もないのに。僕のスタンスは「標準で用意されているものは標準のまま使う。動かなかったら文句言う」という理想的な人柱(笑)。

一応、cpanFCGIなるものをインストールしてみましたが、必要だったかどうかは不明。cpanってremoveコマンドがないのだ。多分要らなかったんじゃないかと思う。

# cpan install FCGI
# cpan install FCGI::Fast

ほんで、必要な*.cgiファイルを*.fcgiに改名するだけ。ここでは、CGIモードでも使えるよう、シンボリックリンクを張っておく。

# ln -s mt.cgi mt.fcgi
# ln -s mt-comments.cgi mt-comments.fcgi
# ln -s mt-tb.cgi mt-tb.fcgi
# ln -s mt-search.cgi mt-search.fcgi

さらに、mt-config.cgiに下記の行を追加して、スクリプト名を変更する。

# For Using FastCGI
AdminScript mt.fcgi
CommentScript mt-comments.fcgi
TrackbackScript mt-tb.fcgi
SearchScript mt-search.fcgi

一応、mt/index.htmlも修正しておこう。

<p class="login"><a rel="nofollow" href="mt.fcgi">ログイン</a></p>

ただし、mod_fcgid のデフォルトのcommunication timeoutが20秒と少ないので、このままでは500 Internal Server Errorが発生する可能性が高い。Apacheの設定で下記のように上書きする。せっかくなので、fcgid.conf の最後に書くのが良いだろう。場合によってはもっと大きな値が必要かもしれない。

IPCCommTimeout 180

【参考URL】
http://as-is.net/blog/archives/001148.html
http://fastcgi.coremail.cn/doc.htm