How to Install Nagios 4 in Ubuntu and Debian

how to install nagios 4 in ubuntu and debian

Nagios is a popular software used to monitor websites, network, hardware, servers and more. It is an enterprise-grade monitoring and log monitoring system. Let us look at how to install Nagios 4 in Ubuntu and Debian systems.


How to Install Nagios 4 in Ubuntu and Debian

Here are the steps to install Nagios 4 in Ubuntu and Debian


1. Install Apache in Ubuntu/Debian

Nagios 4 runs on Apache so you need to install it before installing Nagios server. We also update system packages to ensure smooth installation of Apache.

$ sudo apt update
$ sudo apt install apache2


2. Install PHP

Nagios also requires PHP to be installed. If you haven’t installed it yet, Nagios will automatically install PHP when you run its installation. You can also install it on your own, with the command:

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


3. Install Nagios Server packages

Install Nagios with the following command

$ sudo apt install nagios3 nagios-plugins-basic

In fact, Nagios will also monitor itself, in addition to monitoring your website infrastructure.


You will see a prompt to create password for nagiosadmin user account.


Create a password and continue.


4. Configure Nagios Server

To configure Nagios Server, open its config file in a text editor.

$ sudo nano /etc/nagios3/nagios.cfg

Add the line in bold, save and quit 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 open Apache’s Nagios config file in a text editor

$ sudo nano /etc/nagios3/apache2.conf


Update the access to be limited to 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 and close the file


Next, update user permissions for Nagios folders

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


Then restart Nagios and Apache

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


Open your web browser and visit http://localhost/nagios3

You will be asked for username & password. Enter username as “nagiosadmin” and enter its password that you created in step 3.

You will see the admin screen

how to install nagios 4 in ubuntu and debian


About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!