Nagios is the most widely used open-source monitoring system to monitor the networks, servers, services and applications which are running on Windows and Linux operating systems. It will notify alerts on failure or suboptimal performance. In this article we will learn how to install Nagios on Ubuntu 20.04.
Step 1 – Prerequisites
You must logged in as root or user with sudo privileges.
Step 2 – Installing Nagios on Ubuntu
By default, the Ubuntu standard repositories includes the Nagios 4. The installation is straightforward, just run the following commands:
sudo apt update
sudo apt install nagios4 nagios-plugins-contrib nagios-nrpe-plugin
The above commands will install required packages, Nagios Core, Nagios Plugins, and Apache.
By default, the Apache configuration file ships with Nagios which depends on the
mod_auth_digest modules. These are disabled by default and you should enable both of these to allow or deny access to authenticated by group membership, and
mod_authz_groupfile enables the MD5 digest authentication.
Run the following commands to enable the both modules:
sudo a2enmod authz_groupfile auth_digest
Step 3 – Apache Configuration
Nagios is allowed to access only from localhost and private IPs due to the Apache default configuration. Now we will change the configuration so only allowed user can access and view.
Open the configuration file with your text editor:
sudo nano /etc/apache2/conf-enabled/nagios4-cgi.conf
Find the line starts with
Require ip and
Require all granted and uncomment the line containing
Save and close the file. After that restart the Apache service to take effect of configuration:
sudo systemctl restart apache2
Check the status of Apache and Nagios wether it is working proper or not by typing:
sudo systemctl status apache2
sudo systemctl status nagios4
Step 4 – Creating User Account
The username “
nagiosadmin” having the administrative privileges by default in Nagios. With this user, you can log in to the Nagios web interface and manage your inventory.
To create a new user you should use
sudo htdigest -c /etc/nagios4/htdigest.users Nagios4 nagiosadmin
It will prompt to enter and confirm the user’s password.
New password: Re-type new password: Adding password for user nagiosadmin
It’s again required to restart the Apache service for changes to take effect:
sudo systemctl restart apache2
Step 5 – Configuring Firewall
If your system is secured firewall, you should open the HTTP and HTTPS ports:
sudo ufw allow Apache
Step 6 – Access Nagios Web Interface
Open your web browser and type the server’s public ip or domain name followed by
/nagios to access the Nagios web interface:
Enter the user name and password as we previously created and it will redirect to home page on successful authentication.
That’s it. You can manage all servers, service and applications using Nagios.
You have successfully learned how to install Nagios on Ubuntu 20.04 system. To know more about the Nagios visit official documentation.
If you have any questions or suggestion, please leave comment below.