首先查看系统是否安装这些基础套件:
[iyunv@nagios ~]# rpm -q gcc glibc glibc-common gd gd-devel xinetd openssl-devel
package gcc is not installed
glibc-2.12-1.107.el6.x86_64
glibc-common-2.12-1.107.el6.x86_64
package gd is not installed
package gd-devel is not installed
package xinetd is not installed
package openssl-devel is not installed
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
编译完成以后,依据提示,运行make all:
写道
[iyunv@nagios nagios]# make all
*** Compile finished ***
If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install
- This installs the main program, CGIs, and HTML files
make install-init
- This installs the init script in /etc/rc.d/init.d
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
make install-webconf
- This installs the Apache config file for the Nagios
web interface
make install-exfoliation
- This installs the Exfoliation theme for the Nagios
web interface
make install-classicui
- This installs the classic theme for the Nagios
web interface
按照提示一步一步安装,并添加Nagios服务:
写道
[iyunv@nagios nagios]# make install
[iyunv@nagios nagios]# make install-init
[iyunv@nagios nagios]# make install-commandmode
[iyunv@nagios nagios]# make install-config
[iyunv@nagios nagios]# chkconfig --add nagios
[iyunv@nagios nagios]# chkconfig --level 35 nagios on
[iyunv@nagios nagios]# chkconfig --list nagios
nagios 0:关闭1:关闭2:关闭3:启用4:启用5:启用6:关闭
[iyunv@nagios src]# wget http://archive.apache.org/dist/httpd/httpd-2.2.26.tar.gz
[iyunv@nagios src]# tar xzvf httpd-2.2.26.tar.gz
[iyunv@nagios src]# cd httpd-2.2.26
[iyunv@nagios httpd-2.2.26]# ./configure --prefix=/usr/local/apache2
[iyunv@nagios httpd-2.2.26]# make && make install
安装Php
写道
[iyunv@nagios src]# wget http://cn2.php.net/distributions/php-5.5.6.tar.gz
[iyunv@nagios src]# tar xzvf php-5.5.6.tar.gz
[iyunv@nagios src]# cd php-5.5.6
[iyunv@nagios php-5.5.6]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
编译时出现报错:
checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
[iyunv@nagios bin]# ./httpd -t -f /usr/local/apache2/conf/httpd.conf
httpd: apr_sockaddr_info_get() failed for nagios.localdomain
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Syntax OK
[iyunv@nagios php-5.5.6]# /usr/local/apache2/bin/apachectl start
httpd: apr_sockaddr_info_get() failed for nagios.localdomain
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[iyunv@nagios etc]# vim resource.cfg
# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/local/nagios/libexec
其中,变量$USER1$指定了安装nagios插件的路径,如果把插件安装在了其它路径,只需在这里进行修改即可。需要注意的是,变量必须先定义,然后才能在其它配置文件中进行引用