How to Install Nagios Server on Ubuntu Linux Server

This brief tutorial shows students and new users how to install and configure the Nagios monitoring server on Ubuntu 16.04 | 17.10 | 18.04 LTS servers.

For those who don’t know about Nagios, it’s software that is used to monitor networks, hardware, servers, and other devices connected to a network. A complete enterprise-grade network, server, and log monitoring system.

This post will show you how to perform a basic configuration after installation. You’ll also be able to log on to the Nagios server once installed.

For more about Nagios, please visit its homepage.

When you’re ready, continue below with the steps:

Install Apache2

Before installing Nagios server packages, make sure the Apache2 HTTP server is installed. to do that on Ubuntu run the commands below.

sudo apt update
sudo apt install apache2

Install PHP Packages

Nagios server also requires that PHP and related modules be installed. If you don’t have these already, it will automatically install them when you run the commands to install Nagios. The commands below install PHP and related packages.

sudo apt install php php-cgi libapache2-mod-php php-common php-pear php-mbstring

Install Nagios Server Packages

To get Nagios on Ubuntu systems, run the commands below. the commands also include a basic plugin to monitor the Nagios server itself.

sudo apt install nagios3 nagios-plugins-basic

When you run the above command. you’ll be prompted to create a password for nagiosadmin account.

  ┌─────────────────────────────────────────────────┤ Configuring nagios3-cgi ├─────────────────────────────────────────────────┐
  │ Please provide the password to be created with the "nagiosadmin" user.                                                      │ 
  │                                                                                                                             │ 
  │ This is the username and password you will use to log in to your nagios installation after configuration is complete.  If   │ 
  │ you do not provide a password, you will have to configure access to nagios yourself.                                        │ 
  │                                                                                                                             │ 
  │ Nagios web administration password:                                                                                         │ 
  │                                                                                                                             │ 
  │ ___________________________________________________________________________________________________________________________ │ 
  │                                                                                                                             │ 
  │                                              <Ok>                                                                           │ 
  │                                                                                                                             │ 

Create one a continue

Configure Nagios Server

Now that the Nagios server is installed, run the commands below to open its default configuration file.

sudo nano /etc/nagios3/nagios.cfg

Then make the highlighted changes below and save the file.

# This option allows you to specify whether or not Nagios should check
# for external commands (in the command file defined below).  By default
# Nagios will *not* check for external commands, just to be on the
# cautious side.  If you want to be able to use the CGI command interface
# you will have to enable this.
# Values: 0 = disable commands, 1 = enable commands


Next, run the commands below to open Nagios Apache2 config file.

sudo nano /etc/nagios3/apache2.conf

Then limit access from the localhost and local subnet only.

# nagios 1.x:
#Alias /nagios /usr/share/nagios3/htdocs

<DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
        Options FollowSymLinks
        DirectoryIndex index.php index.html
        AllowOverride AuthConfig
   <IfVersion < 2.3>
       Order Allow,Deny
       Allow From localhost

Save the file and continue below.

Next, run the commands below to adjust the Nagios folder permissions.

sudo chgrp -R www-data /var/lib/nagios3 
sudo root@dlp:~# chmod 750 /var/lib/nagios3/rw

After that restart Nagios2 and Apache2

sudo systemctl restart nagios3.service
sudo systemctl restart apache2.service

Finally, open your browser and browse to the server hostname or IP address, and log on to the Nagios server.


with username: nagiosadmin and the password you created above.

Nagios ubuntu install

That’s it!

You may also like the post below: