Saturday, September 3, 2011

cactiをnginxで動かすためのメモ

cactiをnginxで動かすためのメモ。

upstream php {
        server unix:/var/run/php-cgi.sock fail_timeout=0;
        server localhost:9000 fail_timeout=0 backup;
}

server {
        listen 80;

        server_name     cacti.localnet;
        root /usr/share/cacti/site;

        location / {
                index index.php;
                location ~ .php$ {
                        include "/etc/nginx/fastcgi_params";
                        fastcgi_pass   php;      
                        fastcgi_index  index.php;
                        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                }
        }
}

php5-cgi をうごかしておく

# php5-cgi -q -b /var/run/php-cgi.sock & 
# php5-cgi -q -b localhost:9000 &

でもphp5-cgiはいつのまにか死ぬことがあるのでwhile trueのloopで実行したほうがいいかもしれない。

#!/bin/sh

while true; do
  php5-cgi -q -b /var/run/php-cgi.sock
done

No comments: