■NginxでPerlが動作する様にfcgiwrapとspawn-fcgiのインストールと設定
・epelレポジトリを使用してspawn-fcgiとfcgi-develのインストール
# yum --enablerepo=epel install spawn-fcgi fcgi-devel
# yum groupinstall "Development Tools"
・fcgiwrapのインストール
Simple CGI support for Nginx (fcgiwrap)
https://nginx.localdomain.pl/wiki/FcgiWrap
https://github.com/gnosek/fcgiwrap/blob/master/README.rst
・上記サイトの説明に従ってダウンロードとインストール
# wget -O gnosek-fcgiwrap.tar.gz http://github.com/gnosek/fcgiwrap/tarball/master
※githubから落として来いと言われ保存するファイル名を指定
# tar zxvf gnosek-fcgiwrap.tar.gz
# cd gnosek-fcgiwrap-66e7b7d
# autoreconf -i
# ./configure
# make
# make install
・設定
# vim /etc/sysconfig/spawn-fcgi
#追記
OPTIONS="-u nginx -g nginx -a 127.0.0.1 -p 9001 -P /var/run/spawn-fcgi.pid -- /usr/local/sbin/fcgiwrap"
・nginx設定ファイルのServer Blockへの追記
# vim /etc/nginx/conf.d/default.conf
location ~ \.pl|cgi$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
書式チェック
# /etc/init.d/nginx configtest
# /etc/init.d/nginx restart
# /etc/rc.d/init.d/spawn-fcgi start
# chkconfig spawn-fcgi on
# chkconfig spawn-fcgi –list
spawn-fcgi 0:off 1:off 2:on 3:on 4:on 5:on 6:off
あとは、設置しているCGIで動作確認を行う。
設定ファイルにaccess_logとerror_logの設定済みが前提ではありますが、
駄目な場合はnginxのエラーログから確認。