nginx配置cgi-bin运行perl

系统装的是Gentoo
实际上在gentoo上面如果用apache的话那装nagios是相当方便的,但我就是想把nagios装在nginx上面没办法^_^

wget http://www.nginx.eu/nginx-fcgi/nginx-fcgi.txt
mv nginx-fcgi.txt nginx-fcgi.pl
mv nginx-fcgi.pl /usr/bin/
chmod 777 /usr/bin/nginx-fcgi.pl
 
perl -MCPAN -e shell
cpan> install FCGI
cpan> install IO::All
cpan> install Socket
 
nginx-fcgi.pl -l /tmp/nginx-fcgi.log -pid /tmp/nginx-fcgi.pid -S /tmp/nginx-fcgi.sock
chmod 777 /tmp/nginx-fcgi.*
 
vi /etc/nginx/vhosts/nagios.conf
server
{
  listen       80;
  server_name  nagios.yemaosheng.com;
  index index.php index.html index.htm;
  root  /usr/local/nagios/share;
  location ~ .*\.php?$
  {
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_index   index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME /usr/local/nagios/share$fastcgi_script_name;
  }
  location /nagios/
  {
    gzip off;
    alias /usr/local/nagios/share/;
    index index.html index.htm index.php;
  }
  location ~ \.cgi$ {
     rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
     fastcgi_pass unix:/tmp/nginx-fcgi.sock;
     fastcgi_index index.cgi;
     fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name;
     fastcgi_param HTTP_ACCEPT_LANGUAGE en_US;
     include fastcgi_params;
  }
  location ~ \.pl$ {
     fastcgi_pass  unix:/tmp/nginx-fcgi.sock;
     fastcgi_index index.pl;
     fastcgi_param SCRIPT_FILENAME  /usr/local/nagios/sbin$fastcgi_script_name;
     include /etc/nginx/fastcgi_params;
  }
}
点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注