文章目录

Nginx8 + nagios3.2 +perl fcgi

通常使用:nginx 代理+ apache CGI部分交给apache来处理
本文取消apache 改为nginx自己处理

Nginx nagios 安装略

安装perl cgi模块

wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz
tar -zxvf FCGI-0.67.tar.gz
cd FCGI-0.67
perl Makefile.PL
make && make install
`</pre>
<!--more-->

安装FCGI-ProcManager:
<pre>`wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.18.tar.gz
tar -xzxf FCGI-ProcManager-0.18.tar.gz
cd FCGI-ProcManager-0.18
perl Makefile.PL
make      make install
`</pre>
下载nginx-fcgi脚本
Wget http://www.nginx.eu/nginx-fcgi/nginx-fcgi.txt
放置在:/etc/nginx-fcgi
启动方法:
/etc/nginx-fcgi –l /var/log/nginx/nginx-fcgi.log -pid /var/run/nginx-fcgi.pid -S /var/run/nginx-fcgi.sock
注意给 nginx-fcgi.sock 777的权限

**运行前使用cpan 安装 FCGI;Getopt::Long;IO::All;Socket;**

配置文件参考:/usr/local/nginx/conf/vhosts/nagios.conf
<pre>`server
{
listen 80;
server_name IP;
root /usr/local/nagios/share;
index index.php;
location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include enable_php5.conf;
auth_basic "Nagios Login pain";
auth_basic_user_file /usr/local/nagios/etc/htpasswd;
}
location ~ .*\.cgi$ {
root /usr/local/nagios/sbin;
rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
fastcgi_pass unix:/var/run/ng-fcgi.sock;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin/$fastcgi_script_name;
fastcgi_param HTTP_ACCEPT_LANGUAGE zh-cn;
include enable_php5.conf;
auth_basic "Nagios Login pain";
auth_basic_user_file /usr/local/nagios/etc/htpasswd;
}
location /nagios/ {
alias /usr/local/nagios/share/;
}
`</pre>
enable_php5.conf 参考:
<pre>`fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTP_ACCEPT_ENCODING gzip,deflate;

参考:http://bbs.linuxtone.org/thread-4441-1-1.html
http://www.nginx.eu/nginx-fcgi.html
http://wiki.nginx.org/NginxSimpleCGI

文章目录