本次安装环境是RHEL5.5server。
一、创建nagios用户和用户组
[root@localhost ~]#useradd -s /sbin/nologin nagios
[root@localhost ~]#mkdir /usr/local/nagios
[root@localhost ~]#chown -R nagios.nagios /usr/local/nagios
二、开启系统sendmail服务
[root@localhost ~]#service sendmail start
三、编译安装nagios
[root@localhost ~]# tar -zxvf nagios-3.2.0.tar.gz
[root@localhost ~]# cd nagios-3.2.0
[root@localhost nagios-3.2.0]#./configure --prefix=/usr/local/nagios
#指定nagios的安装目录,这里指定nagios安装到/usr/local/nagios目录
[root@localhost nagios-3.2.0]#make all
[root@localhost nagios-3.2.0]#make install
# make install用来安装nagios的主程序,CGI和HTML文件
[root@localhost nagios-3.2.0]# make install-init
#通过make install-init命令可以在/etc/rc.d/init.d目录下创建nagios启动脚本
[root@localhost nagios-3.2.0]# make install-commandmode
#通过make install-commandmode命令来配置目录权限
[root@localhost nagios-3.2.0]# make install-config
#make install-cofig命令用来安装nagios示例配置文件,这里安装的路径是/usr/local/nagios/etc
nagios安装完成后,目录对应的功能说明如下:
bin:可执行程序所在目录
etc:配置文件所在目录
sbin:cgi文件所在目录,也就是执行外部命令所需文件所在目录
share:网页文件所在目录
libexec:外部插件所在目录
var:日志文件,lock等文件所在目录
var/archives:日志自动归档目录
var/rw:用来存放外部命令文件的目录
四、安装nagios的插件
以nagios-plugins-1.4.14为例,插件版本与nagios版本关系并不大。
[root@localhost nagios]#tar -zxvf nagios-plugins-1.4.14.tar.gz
[root@localhost nagios]#cd nagios-plugins-1.4.14
[root@localhost nagios-plugins-1.4.14]#./configure --prefix=/usr/local/nagios
[root@localhost nagios-plugins-1.4.14]# make
[root@localhost nagios-plugins-1.4.14]# make install
查看/usr/local/nagios/libexec,会看到新增很多的插件。
五、安装Nagios中文化插件
下载地址:http://sourceforge.net/projects/nagios-cn/files/
此处切忌版本要与nagios的版本对应。
[root@localhost ~]#tar jxvf nagios-cn-3.2.0.tar.bz2
[root@localhost nagios-cn-3.2.0]#cd nagios-cn-3.2.0
[root@localhost nagios-cn-3.2.0]#./configure
[root@localhost nagios-cn-3.2.0]#make all
[root@localhost nagios-cn-3.2.0]#make install
六、安装httpd和php
依次执行如下命令:
[root@localhost nagios-cn-3.2.0]#rpm -ivh httpd-2.2.3-43.el5.i386.rpm
[root@localhost nagios-cn-3.2.0]#rpm -ivh php-common-5.1.6-27.el5.i386.rpm
[root@localhost nagios-cn-3.2.0]#rpm -ivh php-cli-5.1.6-27.el5.i386.rpm
[root@localhost nagios-cn-3.2.0]#rpm -ivh php-5.1.6-27.el5.i386.rpm
以上软件包从安装盘中的server目录中寻找。
七、配置httpd和php
修改httpd的配置文件/etc/httpd/conf/httpd.conf
找到如下两行
User apache
Group apache
#如果找不到,请通过搜索nobody寻找
修改为
User nagios
Group nagios
然后找到
DirectoryIndex index.html index.html.var
修改为
DirectoryIndex index.html index.html.var index.php
再在其下增加如下行
AddType application/x-httpd-php .php
