# [so] Nagios won't execute CGI but has me download it instead

## maiku

I installed Nagios via this article:

http://wiki.gentoo.org/wiki/Nagios

And now every time I go to click on a menu item on the /nagios page, it asks me to download the .cgi script instead of executing it. What could I be missing in the install?

----------

## szatox

I suppose whatever http server you have installed with nagios has cgi module disabled

----------

## maiku

I thought so too, but I tested CGI execution. Plus my /etc/conf.d/apache2 says: *Quote:*   

> APACHE2_OPTS="-D INFO -D LANGUAGE -D SSL -D SUEXEC -D PHP -D PERL -D PHP5 -D DAV -D NAGIOS"

 So there is definitely something else gone wrong!

----------

## e3k

 *maiku wrote:*   

> I thought so too, but I tested CGI execution. Plus my /etc/conf.d/apache2 says: *Quote:*   APACHE2_OPTS="-D INFO -D LANGUAGE -D SSL -D SUEXEC -D PHP -D PERL -D PHP5 -D DAV -D NAGIOS" So there is definitely something else gone wrong!

 

please check if your apache user is in the nagcmd group.

----------

## maiku

Thanks for the reply. I don't have a nagcmd group, but the user nagios is a part of the group apache and vice versa:

/etc/group *Quote:*   

> apache:x:81:nagios
> 
> nagios:x:1002:apache

 But it still doesn't execute the CGI.

----------

## e3k

 *maiku wrote:*   

> Thanks for the reply. I don't have a nagcmd group, but the user nagios is a part of the group apache and vice versa:
> 
> /etc/group *Quote:*   apache:x:81:nagios
> 
> nagios:x:1002:apache But it still doesn't execute the CGI.

 

could you please print here the ls -l of the CGIs?

----------

## maiku

 *e3k wrote:*   

> could you please print here the ls -l of the CGIs?

 Do you mean this? *Quote:*   

> # ls -l /usr/lib64/nagios/cgi-bin/
> 
> total 4192
> 
> -rwxr-xr-x 1 root root 297512 Mar 13 22:02 avail.cgi
> ...

 

----------

## e3k

 *maiku wrote:*   

>  *e3k wrote:*   could you please print here the ls -l of the CGIs? Do you mean this? *Quote:*   # ls -l /usr/lib64/nagios/cgi-bin/
> 
> total 4192
> 
> -rwxr-xr-x 1 root root 297512 Mar 13 22:02 avail.cgi
> ...

 

others have rx seems fine for me.. next i would check the nagios/apache config file maybe the path here: http://nagiosbook.org/html/ch05s03.html is the same on gentoo.

----------

## maiku

 *e3k wrote:*   

> others have rx seems fine for me.. next i would check the nagios/apache config file maybe the path here: http://nagiosbook.org/html/ch05s03.html is the same on gentoo.

 The config file seems okay: *Quote:*   

> <IfDefine NAGIOS>
> 
>         ScriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi-bin/
> 
>         <Directory "/usr/lib/nagios/cgi-bin/">
> ...

 It is defined as you can see in my /etc/conf.d/apache2: *Quote:*   

> APACHE2_OPTS="-D INFO -D LANGUAGE -D SSL -D SUEXEC -D PHP -D PERL -D PHP5 -D DAV -D NAGIOS"

 

----------

## e3k

 *maiku wrote:*   

> It is defined as you can see in my /etc/conf.d/apache2: *Quote:*   APACHE2_OPTS="-D INFO -D LANGUAGE -D SSL -D SUEXEC -D PHP -D PERL -D PHP5 -D DAV -D NAGIOS" 

 

according to this thread: https://forums.gentoo.org/viewtopic-t-977636-view-previous.html?sid=145597f17ecc2e11762621b4d38f5e44

you need to define -D CGI in APACHE2_OPTS and also please make sure that apache was compiled with APACHE2_MODULES="cgi" in make.conf

----------

## maiku

That was it! That fixed it. I had to reinstall apache with CGI support and enable it. Thank you!

----------

