みかづきの色々

デバイス(スマホからキャンプ用品まで)とかプログラミングとか中心のいろいろ試験的なブログ。

nginxにcgiとphp対応を追加するよー。

まず、以下をインストールかな。
環境は Debian wheezy ね。

# aptitude search php5-fpm
i   php5-fpm                                        - server-side, HTML-embedded scripting language (FPM-CGI bin
#
# aptitude search fcgiwrap
i   fcgiwrap                                        - simple server to run CGI applications over FastCGI
#

そんでもって、

# aptitude install nginx-full

であるな。

んで、/etc/nginx/sites-enabled/default に以下を。
書いてる内容の意味は、ある程度UNIXスキルがあればわかると思うが、
UNIXソケットを使って実行せよ(そしてソケットの場所はここと指定)と示して、
まぁあとは細かい設定だ。

        location /cgi-bin/ {
                gzip off;
                root /usr/lib;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
                include /etc/nginx/fastcgi_params;
                fastcgi_param SCRIPT_FILENAME /usr/lib/$fastcgi_script_name;
        }

        location ~ \.php$ {
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }