一、安装环境
1.系统 ubuntu-12.04.1-desktop-amd64.iso
2.虚拟机 VMware® Workstation 8.0.4 build-744019
3.远程工具 xshell4
二、安装步骤
1.apt-get install ssh
2.创建nagiios用户和用户组
root@ubuntu:~# useradd -s /sbin/nologin nagios
root@ubuntu:~# mkdir /usr/local/nagios
root@ubuntu:~# chown -R nagios.nagios /usr/local/nagios
3.开启sendmail服务
4.编译安装 nagios
cd /usr/local/src #切换到软件安装目录
#上传所有的安装文件
tar -zxvf nagios-3.2.0.tar.gz
cd nagios-3.2.0/
./configure --prefix=/usr/local/nagios
make all
make install #安装主程序和CGI、HTML文件
make install-init #在/etc/rc.d/init.d目录下创建nagios启动脚本
make install-commandmode #配置目录权限
make install-config #安装示例文件
#设置开机自启动
apt-get install chkconfig
$sudo ln -s /usr/lib/insserv/insserv /sbin/insserv
chkconfig --add nagios
chkconfig --level 35 nagios on
chkconfig --list nagios
5.安装nagios插件
tar -xzvf nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.14/
./configure --prefix=/usr/local/nagios
make
make install
6.安装配置apache
tar -xzvf httpd-2.0.63.tar.gz
cd httpd-2.0.63/
./configure --prefix=/usr/local/apache2
make
make install
7.安装php
apt-get install libxml2
apt-get install libxml2-dev
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
apt-get install libxml2-dev
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
make
make install
8.配置apache
User nagios
Group nagios
#setting for nagios
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 None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml
AddType applicatoin/x-httpd-php-source .phps
9.生成密码
/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd nagios
10.启动apache
/usr/local/apache2/bin/apachectl start
有可能有出现的问题
1.php make的时候报错
configure: error: xml2-config not found. Please check your libxml2 installation.
apt-get install libxml2
apt-get install libxml2-dev
2.httpd: Could not determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
修改httpd.conf文件,把其中到#ServerName的注释去掉即可。
vi /usr/local/apache2/conf/httpd.conf
3.You don't have permission to access /nagios/ on this server
这是解析出错了,需要查看 tail -f /usr/local/apache2/logs/error_log 进行具体的分析,有可能是配置文件 ,也有可能是权限问题.
看到报错信息 attempt to invoke directory as script: /usr/local/nagios/share/
原来share目录不能配成ScriptAlias,而只能配成 Alias