つまり、あなたはCGIを使いたい。OK!できるだけ簡単にやってみましょう。
今では、Debian および Ubuntu のためのパッケージがあります。簡単な種類
aptitude install fcgiwrap
そして、 /usr/share/doc/fcgiwrap/README.Debianをみます。/usr/share/doc/fcgiwrap/examples/nginx.conf に設定例があります。
ここでしたことは設定例のローカルコピーを作成しました(つまり、updateで上書きされません)。
cp /usr/share/doc/fcgiwrap/examples/nginx.conf /etc/nginx/fcgiwrap.conf
そして、それを"server"セクションのサイトの設定に追加します
# fast cgi support
include /etc/nginx/fcgiwrap.conf;
パッケージをインストールした後で、ngx_http_fastcgi_moduleドキュメントあるいはFastCGI 例も見ます。
ここでの最初のステップはこれをインストールします。
aptベースのシステムであれば:
aptitude install git-core build-essential libfcgi-dev autoconf libtool automake
ソースを取得します:
cd /usr/local/src/
git clone git://github.com/gnosek/fcgiwrap.git
これをコンパイルします:
cd /usr/local/src/fcgiwrap
autoreconf -i
./configure
make
mv fcgiwrap /usr/local/bin/
#!/usr/bin/perl
use strict;
use warnings FATAL => qw( all );
use IO::Socket::UNIX;
my $bin_path = '/usr/local/bin/fcgiwrap';
my $socket_path = $ARGV[0] || '/tmp/cgi.sock';
my $num_children = $ARGV[1] || 1;
close STDIN;
unlink $socket_path;
my $socket = IO::Socket::UNIX->new(
Local => $socket_path,
Listen => 100,
);
die "Cannot create socket at $socket_path: $!\n" unless $socket;
for (1 .. $num_children) {
my $pid = fork;
die "Cannot fork: $!" unless defined $pid;
next if $pid;
exec $bin_path;
die "Failed to exec $bin_path: $!\n";
}
chmod +x /etc/init.d/fcgiwrap
するのを忘れないでください。
私はあまりに複雑なinitスクリプトを作成しないようにすると決め、単純なものに落ち着きました。exit 0 行の前に、単にsudo -u www-data /etc/init.d/fcgiwrap
を /etc/rc.local
に追加しました。
sudo コマンドはwww-dataユーザで fcgiwrapper initスクリプトを起動するでしょう。スクリプトは/tmp/cgi.sock
にlistenerスレッドをもたらします。これはfastcgi_pass の中で使用する必要があるものです: fastcgi_pass unix:/tmp/cgi.sock;