Setting Up The Web Interface


In these instructions I will assume that you are running the Apache web server on your machine. If you are using some other web server, you'll have to make changes where appropriate. I am also assuming that you used the /usr/local/nagios as the installation prefix.

Configure Script Alias For The CGIs

You'll need to create an alias for the CGIs as well. The default installation expects to find them accessible at http://yourmachine/nagios/cgi-bin/, although this can be changed using the --with-cgiurl option in the configure script. Anyway, add something like the following to your web server configuration file (i.e. httpd.conf) (changing it to match any directory differences on your system)...

ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/
<Directory "/usr/local/nagios/sbin/">
    AllowOverride AuthConfig
    Options ExecCGI
    Order allow,deny
    Allow from all

Important! The Script-Alias line above must come before the Alias line below. Otherwise Apache will parse the lines differently.

Important! If you are installing Nagios on a multi-user system, you may want use CGIWrap to provide additional security between the CGIs and the external command file. If you decide to use CGIWrap, the ScriptAlias you'll end up using will most likely be different from that mentioned above. More information on doing this can be found here.

Configure Alias For The HTML Files

In order to make the HTML files accessible via the web server, you'll have to edit your Apache configuration file as follows...

Add the following to your web server configuration file (i.e. httpd.conf) as follows:

Alias /nagios/ /usr/local/nagios/share/
<Directory "/usr/local/nagios/share">
    Options None
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all

This will allow you to use an URL like http://yourmachine/nagios/ to view the HTML web interface and documentation. The alias should be the same value that you entered for the --with-htmurl argument to the configure script (default is /nagios/).

Important! The Alias directive you just added for the HTML files must come after the ScriptAlias directive for the CGIs. If it doesn't, you'll get a 404 error when attempting to access the CGIs.

Restart The Web Server

Once you've finished editing the Apache configuration file, you'll need to restart the web server with a command like this...

/etc/rc.d/init.d/httpd restart

Verify Your Changes

Don't forget to check and see if the changes you made to Apache work. You should be able to point your web browser at http://yourmachine/nagios and get the web interface for Nagios. The CGIs may not display any information, but this will be remedied once you configure everything and start Nagios.

Configuring Web Authentication

Once you have configured the web interface properly, you'll need to enable web server authentication for accessing the CGIs and configure user authorization information. Details on doing this can be found here.