搭建基於apache的nagios系統比較容易,網上的資料也比較多。但是在nginx環境下就有點費勁了,由於nginx自己不支持CGI,因此須要在三方程序的配合下,才能實現CGI的解析。php
本文只講述安裝部分,有機會再給你們補上配置部分。下面就開始學習在nginx環境下安裝,安裝nagios監控系統。html
準備工做:linux
- wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz
- wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
- wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
- wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz
- wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.18.tar.gz
- wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/IO-1.25.tar.gz
- wget http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.39.tar.gz
- groupadd nagios
- useradd -g nagios nagios
開始安裝:ios
- tar zxvf nagios-3.4.1.tar.gz
- cd nagios
- ./configure --prefix=/data/app/nagios --with-nagios-user=nagios --with-nagios-group=nagios
- make all
- make install
- make install-init
- make install-commandmode
- make install-config
- cd ..
- tar zxvf nagios-plugins-1.4.16.tar.gz
- cd nagios-plugins-1.4.16
- ./configure --prefix=/data/app/nagios --with-nagios-user=nagios --with-nagios-group=nagios
- make
- make install
- cd ..
- tar zxvf nrpe-2.13.tar.gz
- cd nrpe-2.13
- ./configure --prefix=/data/app/nagios --with-nrpe-user=nagios --with-nrpe-group=nagios
- make
- make install
- cd ..
- yum install perl
- tar zxvf FCGI-0.67.tar.gz
- cd FCGI-0.67
- perl Makefile.PL
- make
- make install
- cd ..
- tar zxvf FCGI-ProcManager-0.18.tar.gz
- cd FCGI-ProcManager-0.18
- perl Makefile.PL
- make
- make install
- cd ..
- tar zxvf IO-1.25.tar.gz
- cd IO-1.25
- perl Makefile.PL
- make
- make install
- tar zxvf IO-All-0.39.tar.gz
- cd IO-All-0.39
- perl Makefile.PL
- make
- make install
- cd /data/app/nginx/sbin/
- wget http://www.linux8080.com/perl-fcgi.pl
- chmod +x perl-fcgi.pl
- chown nginx.nginx perl-fcgi.pl
- /data/app/nginx/sbin/perl-fcgi.pl -pid /var/run/nginx-fcgi.pid -S /var/run/nginx-fcgi.sock -l /var/log/perl-fcgi.log
- cd /var/run
- chmod 777 nginx-fcgi.sock
- cd /data/app/nagios/etc/
- htpasswd -c htpasswd nagios
- server {
- listen 80;
- server_name 10.10.10.200;
- index index.html index.htm index.php;
- root /data/www/html;
- location ~ .*\.(cgi|pl)?$
- {
- gzip off;
- root /data/app/nagios/sbin;
- rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
- fastcgi_pass unix:/var/run/nginx-fcgi.sock;
- fastcgi_param SCRIPT_FILENAME /data/app/nagios/sbin$fastcgi_script_name;
- fastcgi_index index.cgi;
- fastcgi_read_timeout 60;
- fastcgi_param REMOTE_USER $remote_user;
- include fcgi.conf;
- }
- location ~ ^/nagios/.+\.php$
- {
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- include fcgi.conf;
- auth_basic "Nagios Access";
- auth_basic_user_file /data/app/nagios/etc/htpasswd;
- }
- }
- ln -s /data/app/nagios/share /data/www/html/nagios
登陸後的界面以下:nginx
注意:文中所涉及到的一部分安裝包,下載連接可能會失效。你們請從個人附件下載。sql
若是你們安裝有問題的話,請及時聯繫我!!apache