第七步: 修改配置文件
vi /etc/httpd/conf/httpd.conf
找到 #ServerName ww.example.com:80 #在276行
修改为 ServerName ww.example.com:80 #这里设置为你自己的域名,如果没有域名,可以设置为localhost
用户组设置
User apache
Group apache
User nagios
Group nagios
如果初期设置没有nagios用户 需要创建nagios用户
# useradd -s /sbin/nologin nagios
# mkdir /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios
然后找到
DirectoryIndex index.html index.html.var
修改为
DirectoryIndex index.html index.php
接着增加如下内容:
AddType application/x-httpd-php .php
增加nagios
#setting fornagios 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>
AuthUserFile /usr/local/nagios/etc/htpasswd //用于此目录访问身份验证的文件(地址根据自身设置而定)
第八步:创建apache目录验证文件
# htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
第九步:检查nagios 配置文件
/usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg
启动nagios 报错
Error in configuration file'/usr/local/nagios/etc/nagios.cfg' - Line 1043 (UNKNOWN VARIABLE)
找到nagios文件第1043行注释掉
第十步:Nagios 启动成功
Service nagios start
Service httpd start
打开浏览器,输入密码,在host里面应该有“localhost”这台机器
http://{your_ip_address}/nagios
可能其中会出现一些问题
点击各个栏目都弹出下载
解决方案:
是将 apache的配置文件httpd.conf中:LoadModule cgid_module modules/mod_cgid.so前面的#去掉,再重启一下apache就好了。
启动成功