安装软件包:
# yum install -y httpd
# yum install -y php
# yum install -y glibc glibc-common
# yum install -y gd gd-devel
#增加用户和组
# useradd nagios
# passwd nagios
# nagios123
#创建nagcmd组,用于从web接口执行外部命令,将nagios,apache加到这个组中
# groupadd nagcmd
# usermod -G nagcmd nagios
# usermod -G nagcmd apache
#下载源文件和插件
# cd /opt
# wget
# wget
#安装和配置nagios
# cd /opt
# tar zxvf nagios-3.3.1.tar.gz
# cd nagios
yum install gcc #安装gcc包
# ./configure --prefix=/usr/local/nagios --with-command-group=nagcmd
yum install make #安装make包
# make all
# make install
# make install-init
# 如果是freebsd系统,在执行make install-init前必须修改Makefile文件,将INIT_OPTS=-o root -g root修改为:INIT_OPTS=-o root -g wheel,否则会提示
install: root: Invalid argument
*** Error code 67
# make install-config
# make install-commandmode
#配置web接口,安装nagios的web配置文件到apache的conf目录下
# make install-webconf
#如果是freebsd,执行这步前必须修改Makefile,修改httpd的conf文件路径,否则会出错。
#配置一个nagiosadmin用户用于nagios的web接口登录。
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
#安装nagios插件
# cd /opt
# tar zxvf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install
#重启apache服务
# service httpd restart
# 验证nagios.cfg文件,建议在每次修改配置文件后都验证,确认无误后,然后启动nagios服务
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# 启动nagios服务
# service nagios start
#修改SElinux设置,也可以修改/etc/selinux/config使之永久有效
# setenforce 0
#到目前为止,基础的安装已经完成了!打开IE访问Nagios