Nagios is an open-source monitoring tool that is used to monitor hosts, services, and network devices. It provides real-time monitoring, alerting, and reporting capabilities to help you proactively identify and resolve issues in your IT environment. In this article, we will show you how to install Nagios Server on Ubuntu & Debian, including the prerequisites, installation process, and configuration steps.
Nagios Server is the central component of the Nagios monitoring system. It collects data from remote hosts, services, and network devices, and displays the information in a web interface. Nagios Server can be installed on a variety of operating systems, including Ubuntu & Debian. In this article, we will focus on installing Nagios Server on Ubuntu & Debian systems.
Before installing Nagios Server, you should have the following prerequisites:
- A fresh installation of Ubuntu or Debian.
- A non-root user with sudo privileges.
- Internet connection to download the required packages.
Step 1: Update the System
Before installing any new packages, it is always recommended to update the system with the latest security patches and bug fixes. Run the following command to update the system:
sudo apt update && sudo apt upgrade
Step 2: Install Required Packages
Before installing Nagios, you need to install some required packages including Apache, PHP, and GCC. Run the following command to install them:
sudo apt install -y build-essential libgd2-xpm-dev openssl libssl-dev apache2 apache2-utils
Step 3: Create a Nagios User and Group
First of all, create a nagios user using the following command:
sudo adduser nagios
Then create a group for Nagios setup “nagcmd” and add nagios user to this group. Also, add nagios user in the Apache group.
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data
Step 4: Download Nagios Core
You can download Nagios Core from the official website using the wget command. Run the following command to download the latest version of Nagios Core:
After downloading the package, extract it using the tar command. Run the following command to extract the package:
tar xzf nagios-4.4.10.tar.gz
Step 5: Compile and Install Nagios Core
Go to the extracted directory and run the following commands to compile and install Nagios Core:
sudo ./configure --with-command-group=nagcmd --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode
Now create an Apache configuration file for your Nagios server as below:
sudo make install-webconf
Now copy event handlers scripts under libexec directory. These binaries provides multiple events triggers for your Nagios web interface.
sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
Step 6: Configure Apache Web Server
We need to setup apache authentication for user nagiosadmin. Until more specific reason use this username as “nagiosadmin” else you would require more changes in configuration.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Now enable Apache configuration and restart Apache service to make the new settings take effect.
sudo a2enmod cgi rewrite
sudo systemctl restart apache2
Step 7: Install Nagios Plugins
After installing and configuring Nagios core service, Download latest nagios-plugins source and install using the following commands.
tar xzf nagios-plugins-2.4.3.tar.gz
Now compile and install Nagios plugins
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagcmd --with-openssl
sudo make install
Step 8: Start Nagios Service
Use the Nagios commands to verify the Nagios installation and configuration file.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
After successfully verify start the Nagios core service and enable auto-start on system boot..
sudo systemctl start nagios
sudo systemctl enable nagios
Step 9: Access Nagios Web Interface
You can access the Nagios web interface by opening a web browser and entering the following URL:
You will be prompted to enter a username and password. Use the credentials you created in step 6 (nagiosadmin/password) to log in.
Once you are logged in, you will see the Nagios dashboard that displays the status of all the hosts and services being monitored.
In this article, we have introduced Nagios Server, its importance, and the installation process for Ubuntu & Debian systems. Installing Nagios Server will allow you to monitor your IT environment and ensure that critical systems and services are functioning correctly. By following the steps outlined in this article, you can get started with Nagios Server and take the first step towards proactively managing your IT environment.