うまいぼうぶろぐ

linuxとhttpdとperlのメモ

nginx + perl + fastcgi

install fastcgi

# yum install perl-FCGI

setup nginx

  1. /usr/bin/fastcgi-wrapper.pl をdownloadする
  2. /etc/rc.d/init.d/perl-fastcgi をdownload (fastcgi-wrapper.pl をdaemonで起動)
    1. 必要ならOS起動時に起動するようにchkconfig しておく
  3. listenしたtcp port (or unix domain socket) をnginxで指定

  • nginx.conf
location ~ \.cgi($|/) {
  include        fastcgi_params;
  fastcgi_pass   127.0.0.1:8999;
  fastcgi_index  index.cgi;
  fastcgi_split_path_info        ^(.+\.cgi)(/.*)$;
  fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param  PATH_INFO          $fastcgi_path_info;
  fastcgi_param  PATH_TRANSLATED    $document_root$fastcgi_path_info;
}