# Nagios: Could not open CGI config file [SOLVED]

## Ctrl+Alt+Del

Hello fellow Gentoo Users  :Smile: 

I am currently at a loss, i followed the docs on nagios.org and https://forums.gentoo.org/viewtopic-t-262408.html for the mysql instructions.

The Daemon starts alright (yes, the pre-flight check goes trough without any errors or wanrings), but i cannot get the webinterface to work.

Logging in works fine but clicking on any menulink on the left brings up:

Error: Could not open CGI config file '/etc/nagios/cgi.cfg' for reading!

Here are some things you should check in order to resolve this error:

   1. Make sure you've installed a CGI config file in its proper location. See the error message about for details on where the CGI is expecting to find the configuration file. A sample CGI configuration file (named cgi.cfg) can be found in the sample-config/ subdirectory of the Nagios source code distribution.

   2. Make sure the user your web server is running as has permission to read the CGI config file. 

The File cgi.cfg does exist (in /etc/nagios/) , is based on /usr/share/doc/nagios-core-1.3/sample-configs/, belongs to nagios:nagios and is chmodded 644. So the user apache should be able to read the file properly. I have also added the apache user to the nagios group, but no success. I tried chmodding it to 777 as well (shouldn't be necessary, but who knows.)

I have found a few mailinglist and forum reports from fedora users having a similar problem, in their case it worked with apache authentication disabled. Even though that doesn't make any sense to me, i tried it. Disabling Auth didn't change anything.

Neither the Apache error logs nor the nagios logs show any errors when trying to access any of the Nagios Pages.

Any Ideas where to look for an error?Last edited by Ctrl+Alt+Del on Thu Mar 30, 2006 7:25 pm; edited 1 time in total

----------

## gondolin

I'm having the same problem, did you got it working ?

----------

## Ctrl+Alt+Del

Nope i left it aside. Nagios 2.0rc1 went ~x86 a few days ago, maybe i'm gonna give that a shot  :Smile: 

----------

## gondolin

I have no luck with 2.0rc1

just found it on 2.1rc1 , the permissions on /etc/nagios are wrong should be 755

----------

## soth

Same permissionsproblem for me on 2.0_rc2

chmod 755 /etc/nagios...

now I have another problem:

It appears as though you do not have permission to view information for any of the hosts you requested...

If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI

and check the authorization options in your CGI configuration file.

tried with asterisk as to let whoever was authenticated get access to all of nagios, but it doesn't work. 

No messages in apachelog or in /var/nagios/nagios.log either. 

Permissions on /usr/nagios/sbin seems right (755), and so does the files in there...

----------

## Ctrl+Alt+Del

It still does not work for me with rc2 and permissions set to 755.

I do not have the faintest idea on what to do with nagios any more

----------

## soth

Did you check the apache conf?

you need something like this:

```
<IfDefine NAGIOS>

        ScriptAlias /nagios/cgi-bin/ /usr/nagios/sbin/

        <Directory "/usr/nagios/sbin/">

                AllowOverride AuthConfig

                Options ExecCGI

                Order allow,deny

                Allow from all

        </Directory>

        Alias /nagios /usr/nagios/share/

        <Directory "/usr/nagios/share">

                AllowOverride AuthConfig

                Order allow,deny

                Allow from all

         </Directory>

</IfDefine>

```

it's important that you have the AllowOverride AuthConfig and Options ExecCGI. 

Furthermore, you need .htaccess in two places:

```
/usr/nagios/share/
```

and 

```
 /usr/nagios/sbin/
```

The contents of them are in the docs...

Have you got all that?

----------

## Ctrl+Alt+Del

Ok i finally gave it another shot and figured the problem out.

i chmodded all the files in /etc/nagios 755 but not the directory itself, pages are now loading properly

I feel soooo retarted  :Smile: 

----------

## neildotwilliams

I had to change the ownership of the folder.

chown apache:apache /etc/nagios

Well it worked for me!

----------

