Nginx 是一个很牛的高性能Web和反向代理服务器,它具有很多非常优越的特性:在高连接并发的情况下,Nginx是Apache服务器不错的替代品:Nginx在美国是做虚拟主机生意的老板们经常选择的软件平台之一。能够支持高达 50,000 个并发连接数的响应,感谢Nginx为我们选择了 epoll and kqueue作为开发模型。
Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。
1. nagios安装
# wget
# tar zxvf nagios-3.2.2.tar.gz
# cd nagios-3.2.2
# useradd -m -s /bin/bash nagios
# groupadd nagios
# usermod -G nagios nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd www
# ./configure --prefix=/usr/local/nagios --with-command-group=nagcmd
# make
# make all
# make install
# make install-init # 生成init启动脚本
# make install-config # 安装示例配置文件
# make install-commandmode # 设置相应的目录权限
2. nagiox插件安装
# wget
# tar zxvf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local/nagios
# make
# make install
3. nrpe安装
# apt-get install libssl-dev
# wget
# tar zxvf nrpe-2.12.tar.gz
# cd nrpe-2.12
# ./configure
# make all
# cp src/check_nrpe /usr/local/nagios/libexec/
4.安装配置Nginx
#sudo apt-get install nginx php5-fpm libssl-dev fcgiwrap apache2
# htpasswd -c -m /usr/local/nagios/etc/nagiosAdmin.net nagiosadmin
# 启动服务
# /etc/init.d/php5-fpm start
# /etc/init.d/fcgiwrap start #默认是socket模式,socket文件在/var/run/fcgiwrap.socket
# /etc/init.d/nagios start
# /etc/init.d/nginx start
nagios的完整WEB配置
server {
listen 80;
server_name 1.1.1.2;
root /usr/local/nagios/share;
index index.html index.htm index.php default.html default.htm default.php;
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;
auth_basic "nagios admin";
auth_basic_user_file /usr/local/nagios/etc/nagiosAdmin.net;
}
location ~ .*\.cgi$ {
root /usr/local/nagios/sbin;
rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name;
include fastcgi_params;
auth_basic "nagios admin";
auth_basic_user_file /usr/local/nagios/etc/nagiosAdmin.net;
}
location /nagios {
alias /usr/local/nagios/share;
auth_basic "nagios admin";
auth_basic_user_file /usr/local/nagios/etc/nagiosAdmin.net;
}
location ~ .*\.pl$ {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.pl;
fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name;
include fastcgi_params;
}
}