nagios安裝之前的準備,nagios在3.1.x之後需要需要php的支援,所以在這裡就要安裝php和http相關的支援。
一, 建立nagios使用者和組
[root@test2 ~]# useradd -s /sbin/nologin nagios
[root@test2 ~]# mkdir /usr/local/nagios
[root@test2 ~]# chown -R nagios.nagios /usr/local/nagios/
二, http 和php 安裝配置
(1)http安裝
[root@test2 ~]# tar zxvf httpd-2.2.11.tar.gz
[root@test2 ~]# cd httpd-2.2.11
[root@test2 httpd-2.2.11]# ./configure --prefix=/usr/local/apache2 --enable-so
[root@test2 httpd-2.2.11]# make && make install
[root@test2 ~]# /usr/local/apache2/bin/apachectl start
(2)php安裝
[root@test2 ~]# yum install -y libpng libpng-devel libjpeg libjpeg-devel freetype freetype-devel gd gd-devel mysql-devel libxml2-devel libxml2
[root@test2 ~]# mkdir /usr/local/php
[root@test2 ~]# cd php-5.2.9
[root@test2 php-5.2.9]# yum install -y libxml2-devel
[root@test2 php-5.2.9]# ./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache2/bin/apxs
[root@test2 php-5.2.9]# make && make install
(3)配置php和http
修改設定檔[root@test2 ~]# vim /usr/local/apache2/conf/httpd.conf
User nagios
Group nagios
AddType application/x-httpd-php .php
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
三,安裝nagios
(1)安裝nagios
[root@test2 ~]# tar zxvf nagios-3.2.0.tar.gz
[root@test2 ~]# cd nagios-3.2.0
[root@test2 nagios-3.2.0]# ./configure --prefix=/usr/local/nagios/
[root@test2 nagios-3.2.0]# make all
[root@test2 nagios-3.2.0]# make install
[root@test2 nagios-3.2.0]# make install-init 產生開機指令碼
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios
*** Init script installed ***
[root@test2 nagios-3.2.0]# make install-commandmode 修改許可權
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios//var/rw
chmod g+s /usr/local/nagios//var/rw
*** External command directory configured ***
[root@test2 nagios-3.2.0]# make install-config 產生設定檔
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios//etc
(2)nagios外掛程式的安裝
更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/soft/tools/
[root@test2 ~]# tar zxvf nagios-plugins-1.4.9.tar.gz
[root@test2 ~]# cd nagios-plugins-1.4.9
[root@test2 nagios-plugins-1.4.9]# ./configure --prefix=/usr/local/nagios/
[root@test2 nagios-plugins-1.4.9]# make && make install
(3)中文化外掛程式的安裝
注意:這裡的漢化軟體要和nagios 的版本一致,否則會出現問題
[root@test2 ~]# tar jxvf nagios-cn-3.2.0.tar.bz2
[root@test2 ~]# cd nagios-cn-3.2.0
[root@test2 nagios-cn-3.2.0]# ./configure --prefix=/usr/local/nagios/
[root@test2 nagios-cn-3.2.0]# make all
[root@test2 nagios-cn-3.2.0]# make install && make install-init && make install-commandmode && make install-config && make install-webconf
(4)配置安全的http的nagios
[root@test2 ~]# cd /usr/local/apache2/conf/httpd.conf
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
[root@test2 ~]# /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd chenzhongyang
New password:
Re-type new password:
Adding password for user chenzhongyang
四,排錯
一、Starting nagios:This account is currently not available nagios啟動報錯
如果出現如下的提示修改nagios的shell
Starting nagios:This account is currently not available.
# service nagios restart
Running configuration check…done.
Stopping nagios: done.
Starting nagios:This account is currently not available.
done.
解決方案:
修改/etc/passwd
將/sbin/nologin改成/bin/bash