分类: 系统运维
2009-07-29 10:25:06
|
#!/bin/bash #set -x if [[ $# != 1 ]];then echo "usage $0 start|stop|restart" exit 1 fi dir=/usr/local/nginx stop () { #pkill -f $dir/perl-fcgi.pl kill $(cat $dir/logs/perl-fcgi.pid) rm $dir/logs/perl-fcgi.pid 2>/dev/null rm $dir/logs/perl-fcgi.sock 2>/dev/null echo "stop perl-fcgi done" } start () { rm $dir/now_start_perl_fcgi.sh 2>/dev/null chown nobody.root $dir/logs echo "$dir/perl-fcgi.pl -l $dir/logs/perl-fcgi.log -pid $dir/logs/perl-fcgi.pid -S $dir/logs/perl-fcgi.sock" >>$dir/now_start_perl_fcgi.sh chown nobody.nobody $dir/now_start_perl_fcgi.sh chmod u+x $dir/now_start_perl_fcgi.sh sudo -u nobody $dir/now_start_perl_fcgi.sh echo "start perl-fcgi done" } case $1 in stop) stop ;; start) start ;; restart) stop start ;; esac |
location ~* .*\.cgi$ { rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break; include perl_fcgi.conf; } |
gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; |
#!/usr/bin/perl -w print "Content-type: text/plain\r\n\r\n";#发送头信息 print "test"; |
记得一定要给nginx发送头信息 不然会报504错误的。
另:
cgi-bin存在于html目录下时(不是为了部署nagios)
nginx.conf更改下面的部分: location ~* .*\.cgi$ perl_fcgi.conf更改下面的部分: gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
{
include perl_fcgi.conf;
}
fastcgi_pass unix:/usr/local/nginx/logs/perl-fcgi.sock;
fastcgi_index index.cgi;
|
location ~* .*\.cgi$ |
gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string; |
#!/usr/bin/perl -w print "Content-type: text/plain\r\n\r\n";#发送头信息 print "test"; |
记得一定要给nginx发送头信息 不然会报504错误的。
chinaunix网友2009-09-11 11:31:46
非常感谢您,您很热心,monitorix也是属第三方系统监控软件,http://www.monitorix.org/,不是nginx配置文件定义的那个, 我之前按照二种方法,配置正常,但这次采用第一种方法提示找不到 now_start_perl_fcgi.sh文件,是不是跟perl-Getopt和 perl-Socket有关, 还是由脚本创建的,谢谢.我的QQ是7748341方便加我吗?
chinaunix网友2009-09-11 09:26:54
谢谢,呵,按照您的方法可以实现,但有一点我还是不明白, monitorix性能监视安装包里,对于在nginx下实现有说明, 1) Edit the monitorix.conf file to enable the 'nginx' monitorization and put the correct network port where Nginx is listening on: our $ENABLE_NGINX = "Y"; our $NGINX_PORT = "80"; 2) Make sure 'ngnix' is compiled with the flag: --with-http_stub_status_module 3) Edit the nginx.conf file and add or uncomment in the server section the following: location /nginx_status {