wKiom1bWo-Cii9sTAAATvIv7iBc645.png

今天配置安装完成Nagios后,始终无法登录,报错信息如下

Internal Server Error


The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


于是查看先关日志文件,相关报错日志可以在Apache中查看

vi /var/log/httpd/error_log

或者

vi /usr/localapache/logs/error_log

日志提示是验证报错,

nagios could not open password file :/usr/local/nagios/etc/htpasswd

无法打开htpasswd文件,于是进入该目录查看 

cd /usr/local/nagios/etc/htpasswd

原来实际文件为htpasswd.users,漏了users

最后再进入apache中修改httpd.cof文件,在AuthenUserFile 处应填写地址如下

/usr/local/nagios/etc/htpasswd.users

最后重启Apache,Nagios,验证登录,OK,一点感想,还是老话说的好,小心使得万年船!


此外提供其他几个无法登录的排错方法:

1.

htpasswd  -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

默认在root用户下生成的密码文件权限是root的,记得修改成用户nagios的

chown -R nagios.nagios /usr/local/nagios/etc/htpasswd.users


2.修改/etc/selinux/config文件中设置SELINUX=disabled


3.在 httpd.conf 后面 加了验证的

#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
        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>


4.有用 htpasswd 有用htpasswd.users的,Apache默认用的验证文件是htpasswd.users,用别的文件名需要定义

5./usr/local/nagios/etc/cgi.cfg中user 是否为设置密码帐号的那个帐号