基本平台的安装

首先到官方网站(http://www.nagios.org/download/)去下载最新的nagios软件包,本文中使用的是nagios-2.9.tar.gz

1
  nagios用户
代码:
adduser nagios
mkdir /usr/local/nagios
chown nagios.nagios /usr/local/nagios
2  nagios
 
代码:
grep "^User" /etc/httpd/conf/httpd.conf #确定apache的用户,默认是apache /usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd apache #apache的用户名
/usr/sbin/usermod -G nagcmd nagios
3  解压
代码:
tar xzf nagios-version.tar.gz
4  编译
代码:
./configure --prefix=prefix --with-nagios-user=someuser --with-nagios-group=somegroup --with-command-group=cmdgroup

#变量prefix 为安装目录,例如/usr/local/nagios
#变量someuser nagios的用户,例如nagios
#变量somegruop nagios属于的组,例如nagios
#变量cmdgroup nagios命令行属组,例如nagcmd
5  安装
代码:
make all
make install
make install-config
make install-init
6  检查
 
代码:
ls /usr/local/nagios/
bin etc sbin share var #看到这5个目录就ok
7  生成http用户验证文件,用户名为nagios
 
代码:
/usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios
8  nagios的信息加到apache中,打开/etc/httpd/conf/httpd.conf文件,在文件最后添加如下代码:
 
代码:
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
<Directory "/usr/local/nagios/sbin">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>

Alias /nagios /usr/local/nagios/share
<Directory "/usr/local/nagios/share">
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
9  重启apache
 
代码:
/etc/init.d/httpd restart
经过上述9个步骤,如果没有出问题的话,你的nagios页面将神奇的出现在下面的地址,赶快去验收成果吧!

http://IP/nagios