forums.meulie.net

Trouble with apache unable to run cgi

Hello all,
I am in a process of installing Nagios 2.0 on a CentOS system (a free clone of enterprise REDHAT) with apache 2.
I am unable to browse any page except for the homepage, the apache returns Internal Server Error when trying to browse anything else.

Here is what I get in apache error_log:

[Fri Feb 17 02:41:20 2006] [error] [client 192.168.1.50] (13)Permission denied: exec of ‘/usr/lib/nagios/cgi/statuswrl.cgi’ failed, referer: 192.168.1.21/nagios/side.html
[Fri Feb 17 02:41:20 2006] [error] [client 192.168.1.50] Premature end of script headers: statuswrl.cgi, referer: 192.168.1.21/nagios/side.html
[Fri Feb 17 02:41:21 2006] [error] [client 192.168.1.50] (13)Permission denied: exec of ‘/usr/lib/nagios/cgi/statusmap.cgi’ failed, referer: 192.168.1.21/nagios/side.html
[Fri Feb 17 02:41:21 2006] [error] [client 192.168.1.50] Premature end of script headers: statusmap.cgi, referer: 192.168.1.21/nagios/side.html
[Fri Feb 17 02:41:35 2006] [error] [client 192.168.1.50] (13)Permission denied: exec of ‘/usr/lib/nagios/cgi/statuswrl.cgi’ failed, referer: 192.168.1.21/nagios/side.html
[Fri Feb 17 02:41:35 2006] [error] [client 192.168.1.50] Premature end of script headers: statuswrl.cgi, referer: 192.168.1.21/nagios/side.html
[Fri Feb 17 02:41:37 2006] [error] [client 192.168.1.50] (13)Permission denied: exec of ‘/usr/lib/nagios/cgi/statusmap.cgi’ failed, referer: 192.168.1.21/nagios/side.html
[Fri Feb 17 02:41:37 2006] [error] [client 192.168.1.50] Premature end of script headers: statusmap.cgi, referer: 192.168.1.21/nagios/side.html
[Fri Feb 17 02:41:38 2006] [error] [client 192.168.1.50] (13)Permission denied: exec of ‘/usr/lib/nagios/cgi/status.cgi’ failed, referer: 192.168.1.21/nagios/side.html
[Fri Feb 17 02:41:38 2006] [error] [client 192.168.1.50] Premature end of script headers: status.cgi, referer: 192.168.1.21/nagios/side.html

I have checked the security on the directory where cgi-s are located (/usr/lib/nagios/cgi) and for testing purposes have allowed full access for all accounts: chmod -R 777 cgi but still get the error

Does any one have a clue of what’s going on?
Comments are appreciated…

BTW, 192.168.1.21 is the IP of the NAGIOS machine and 1.50 is the cilient browser I connect from…

The nagios docs incorrectly state:
nagios.sourceforge.net/docs/2_0/installweb.html
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
<Directory “/usr/local/nagios/sbin”>
and it should be:
ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/
<Directory “/usr/local/nagios/sbin/”>

modify to suit your system, but dont forget to end the directory with /sbin/ instead of just /sbin

yes, that’s the first thing I looked at, so i corrected to this:

ScriptAlias /nagios/cgi-bin/ “/usr/local/nagios/sbin/”
<Directory “/usr/local/nagios/sbin/”>
AllowOverride AuthConfig
Options ExecCGI
order allow,deny
allow from all

Alias /nagios/ "/usr/local/nagios/share/"
Alias /nagios “/usr/local/nagios/share/”

<Directory “/usr/local/nagios/share/”>
Options None
AllowOverride AuthConfig
order allow,deny
allow from all

still same error…any ideas please?

SELinux enabled? if it is try turning it off and see if it solves.
If you need it enabled there are a couple of threads about it telling how to disable it only for certain services.

Luca

Ah, crap…premature end of script headers…I looked this up once for my setup. It’s on Fedora, which as I’m sure you know is a RedHat project. In this case, it’s probably SElinux, as Luca stated. I found this fix for modifying SELinux to allow the cgi’s to be run (this was for Fedora Core 3, but worked for 4. Give it a try):

chcon -R system_u:object_r:httpd_sys_script_exec_t /usr/local/nagios/sbin

You can check the thread I found here:

issues.apache.org/bugzilla/show_bug.cgi?id=33504

Note that the thread does say more work may need to be done. For me, though, this did the trick quite nicely.