Installing Nagios on Debian Latest
In this tutorial, we will walk through the installation process of Nagios on Debian.
Prerequisites
Before we start the installation process, make sure the following prerequisites are fulfilled.
- You need to have root privileges on the server
- Update the package index and upgrade the system packages to their latest versions.
$ sudo apt update && sudo apt upgrade
Step 1: Install Dependencies
Nagios requires various packages to be installed on the Debian system. To install these dependencies, run the following command:
$ sudo apt install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.3 libgd-dev
Step 2: Download Nagios and its Plugins
Download the latest Nagios source files from the Nagios website using the following command:
$ cd /opt/
$ sudo curl -L -O https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
Next, download the Nagios Plugins:
$ sudo curl -L -O https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
Extract the downloaded files:
$ sudo tar -zxvf nagios-4.4.6.tar.gz
$ sudo tar -zxvf nagios-plugins-2.3.3.tar.gz
Step 3: Compile and Install Nagios
To install Nagios, go to the extracted directory and execute the configure, make, and make install commands.
$ cd nagios-4.4.6/
$ sudo ./configure --with-command-group=nagcmd
$ sudo make all
$ sudo make install
$ sudo make install-commandmode
$ sudo make install-init
$ sudo make install-config
Step 4: Compile and Install Nagios Plugins
Next, install the Nagios plugins by going to the extracted plugin directory and running the same set of commands.
$ cd ../nagios-plugins-2.3.3/
$ sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
$ sudo make
$ sudo make install
Step 5: Setup Nagios User and Group
Create the Nagios user and group to run Nagios on the system.
$ sudo useradd nagios
$ sudo groupadd nagcmd
$ sudo usermod -a -G nagcmd nagios
Step 6: Configure Apache for Nagios
Nagios has a web interface that requires Apache to serve web pages. Configure Apache to serve Nagios pages.
$ sudo make install-webconf
$ sudo a2enmod rewrite
$ sudo systemctl restart apache2
Step 7: Firewall
Nagios uses port 80 for its web interface. Open the HTTP port on the firewall using the following command:
$ sudo ufw allow http/tcp
Step 8: Verify the Installation
Run the following command to start the Nagios service:
$ sudo systemctl start nagios
Navigate to http://localhost/nagios/ in your web browser to ensure Nagios is up and running correctly.
Conclusion
Congratulations! You have successfully installed Nagios on Debian Latest. Nagios can now be used for monitoring hosts and services on your server.