CGI files are downloading, not executing

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
mcamcintyrem
Posts: 10
Joined: Thu May 01, 2014 11:02 am

CGI files are downloading, not executing

Post by mcamcintyrem »

I have spent several hours this morning searching for help on my problem, but nothing is coming up that helps me. So I hope this post helps me out.

I just installed Nagios Core on an Ubuntu 14.04 server. I followed two online guides to help me with the installation:

http://nagios.sourceforge.net/docs/nagi ... buntu.html
http://www.ubuntugeek.com/how-to-instal ... ander.html

The second link helped the most.

Anyway, after doing all of this, I got to the web interface and logged in successfully. However, whenever I click on any of the menu items, my browser wants to download the cgi files, not run them.

Here is my HTTPD.CONF configuration:

Code: Select all

# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file.  Customize the paths, etc. as
# needed to fit your system.

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

<Directory "/usr/local/nagios/sbin">
#  SSLRequireSSL
   Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
   AllowOverride None
   Order allow,deny
   Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /usr/local/nagios/etc/htpasswd.users
   Require valid-user
</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
#  SSLRequireSSL
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /usr/local/nagios/etc/htpasswd.users
   Require valid-user
</Directory>
I would appreciate any support that someone can provide. Thanks.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: CGI files are downloading, not executing

Post by abrist »

Are the cgis executable?

Code: Select all

ls -la /usr/local/nagios/sbin/
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mcamcintyrem
Posts: 10
Joined: Thu May 01, 2014 11:02 am

Re: CGI files are downloading, not executing

Post by mcamcintyrem »

Yes, they are:

Code: Select all

> ls -la /usr/local/nagios/sbin/
total 5136
drwxr-xr-x 2 root   root     4096 May  1 08:00 .
drwxr-xr-x 9 root   root     4096 May  1 07:41 ..
-rwxrwxr-x 1 nagios nagios 316480 May  1 08:00 archivejson.cgi
-rwxrwxr-x 1 nagios nagios 301920 May  1 08:00 avail.cgi
-rwxrwxr-x 1 nagios nagios 300336 May  1 08:00 cmd.cgi
-rwxrwxr-x 1 nagios nagios 273176 May  1 08:00 config.cgi
-rwxrwxr-x 1 nagios nagios 314176 May  1 08:00 extinfo.cgi
-rwxrwxr-x 1 nagios nagios 265168 May  1 08:00 histogram.cgi
-rwxrwxr-x 1 nagios nagios 244552 May  1 08:00 history.cgi
-rwxrwxr-x 1 nagios nagios 240440 May  1 08:00 notifications.cgi
-rwxrwxr-x 1 nagios nagios 318272 May  1 08:00 objectjson.cgi
-rwxrwxr-x 1 nagios nagios 236304 May  1 08:00 outages.cgi
-rwxrwxr-x 1 nagios nagios 240416 May  1 08:00 showlog.cgi
-rwxrwxr-x 1 nagios nagios 314200 May  1 08:00 status.cgi
-rwxrwxr-x 1 nagios nagios 312320 May  1 08:00 statusjson.cgi
-rwxrwxr-x 1 nagios nagios 261136 May  1 08:00 statusmap.cgi
-rwxrwxr-x 1 nagios nagios 256864 May  1 08:00 statuswml.cgi
-rwxrwxr-x 1 nagios nagios 240448 May  1 08:00 statuswrl.cgi
-rwxrwxr-x 1 nagios nagios 265064 May  1 08:00 summary.cgi
-rwxrwxr-x 1 nagios nagios 252776 May  1 08:00 tac.cgi
-rwxrwxr-x 1 nagios nagios 269272 May  1 08:00 trends.cgi
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: CGI files are downloading, not executing

Post by scottwilkerson »

mcamcintyrem wrote: Here is my HTTPD.CONF configuration:

Code: Select all

# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file.  Customize the paths, etc. as
# needed to fit your system.

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

<Directory "/usr/local/nagios/sbin">
#  SSLRequireSSL
   Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
   AllowOverride None
   Order allow,deny
   Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /usr/local/nagios/etc/htpasswd.users
   Require valid-user
</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
#  SSLRequireSSL
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
#  Order deny,allow
#  Deny from all
#  Allow from 127.0.0.1
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /usr/local/nagios/etc/htpasswd.users
   Require valid-user
</Directory>
I would appreciate any support that someone can provide. Thanks.
Is this you httpd.conf or your nagios.conf ? It should be your nagios.conf in the /etc/httpd/conf.d directory

secondly, in your /etc/httpd/conf/http.conf make sure you have the following line

Code: Select all

LoadModule cgi_module modules/mod_cgi.so
If you didn't have it, add it and restart httpd
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
mcamcintyrem
Posts: 10
Joined: Thu May 01, 2014 11:02 am

Re: CGI files are downloading, not executing

Post by mcamcintyrem »

There is no /etc/httpd/conf folder. Could you be referring to /etc/httpd/conf.d/nagios.d ? That folder has a httpd.conf file.
mcamcintyrem
Posts: 10
Joined: Thu May 01, 2014 11:02 am

Re: CGI files are downloading, not executing

Post by mcamcintyrem »

I went ahead and edit that file (/etc/httpd/conf.d/nagios.d/httpd.conf) and inserted the line that you indicated. After restarting Apache, I logged into the web interface. Same problem. CGI's still won't execute. Thus, I reversed my change to the file, going back to the way it was.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: CGI files are downloading, not executing

Post by abrist »

Can you check to make sure the cgi module is loading?

Code: Select all

httpd -M | grep cgi
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mcamcintyrem
Posts: 10
Joined: Thu May 01, 2014 11:02 am

Re: CGI files are downloading, not executing

Post by mcamcintyrem »

When I run the command that you indicate, I get the following:

No command 'httpd' found, di you mean:
Command 'http' from package 'httpie' (Universe)
Command 'xttpd' from package 'xtide' (Universe)
Command 'https' from package 'httpie' (universe)
httpd: command not found
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: CGI files are downloading, not executing

Post by abrist »

How about:

Code: Select all

apache -M | grep cgi
Or:

Code: Select all

apache2 -M | grep cgi
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mcamcintyrem
Posts: 10
Joined: Thu May 01, 2014 11:02 am

Re: CGI files are downloading, not executing

Post by mcamcintyrem »

By executing the second command, I get the following response:

Code: Select all

> apache2 -M | grep cgi
[Thu May 01 16:15:36.026090 2014] [core:warn] [pid 8344] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Thu May 01 16:15:36.026183 2014] [core:warn] [pid 8344] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Thu May 01 16:15:36.026195 2014] [core:warn] [pid 8344] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Thu May 01 16:15:36.026198 2014] [core:warn] [pid 8344] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Thu May 01 16:15:36.026212 2014] [core:warn] [pid 8344] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Thu May 01 16:15:36.034413 2014] [core:warn] [pid 8344] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Thu May 01 16:15:36.034692 2014] [core:warn] [pid 8344] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Thu May 01 16:15:36.034711 2014] [core:warn] [pid 8344] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
Locked