本文相关文档参考:
http://www.xtgly.com/2010/09/21/centos-5-5-nginx-nagios-%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae%e6%8c%87%e5%8d%97.htm
http://www.xtgly.com/2010/09/20/nginx-fastcgi-perl-pl%e3%80%81cgi%e6%94%af%e6%8c%81.htm
1.安装FCGI模块和FCGI-ProcManager模块
要记住http://search.cpan.org这个地址,可以搜索一些perl模块
wget http://search.cpan.org/CPAN/authors/id/B/BO/BOBTFISH/FCGI-0.70.tar.gz |
2.安装 IO 和 IO::ALL模块
cpan install IO IO::All |
3.取消nagios用户认证(方便调试)
vi /usr/local/nagios/etc/cgi.cfg |
4.下载perl-fcgi.pl脚本到/usr/local/nginx/
http://www.xtgly.com/wp-content/uploads/2010/09/perl-fcgi.zip
或者参考如下链接
http://wiki.codemongers.com/NginxSimpleCGI
再创建一个运行脚本,此脚本用来启动/停止perl-fcgi.pl
touch /usr/local/nginx/sbin/perl-fcgi.sh |
perl-fcgi.sh代码如下
- #!/bin/bash
- dir=/usr/local/nginx/
- stop ()
- {kill $(cat $dir/logs/perl-fcgi.pid)}
- start ()
- {sudo -u www /usr/local/nginx/perl-fcgi.pl -l $dir/logs/perl-fcgi.log -pid $dir/logs/perl-fcgi.pid -S $dir/logs/perl-fcgi.sock}
- case $1 in
- stop)
- stop
- ;;
- start)
- start
- ;;
- restart)
- stop
- start
- ;;
- esac
5.修改nginx配置文件,我的配置供参考
- server {
- listen 80;
- server_name localhost;
- root /var/www/html;
- index index.html index.htm index.php;
- location ~ .*\.(php|php5)?$ {
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- }
- location ~ .*\.(cgi|pl)?$ {
- root /usr/local/nagios/sbin;
- rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
- fastcgi_pass unix:/usr/local/nginx/logs/perl-fcgi.sock;
- fastcgi_index index.cgi;
- fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin/$fastcgi_script_name;
- include fastcgi_params;
- }
- location /nginx_status {
- stub_status on;
- access_log off;
- }
- }
6.最后
ln -s /usr/local/nagios/share/ /var/www/html/nagios |
转载于:https://blog.51cto.com/dadaru/463917