UbuntuUbuntu Based

How To Install Nagios on Ubuntu 24.04 LTS

Install Nagios on Ubuntu 24.04

In this tutorial, we will show you how to install Nagios on Ubuntu 24.04 LTS. Monitoring your IT infrastructure is crucial for ensuring optimal performance, availability, and security of your systems. Nagios is a powerful open-source monitoring solution that allows you to keep a watchful eye on your servers, network devices, applications, and services.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Nagios open-source monitoring solution on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • An Ubuntu 24.04 system with root access or a user with sudo privileges.

Install Nagios on Ubuntu 24.04 LTS Noble Numbat

Step 1. Updating the Package Repository.

Before proceeding with the installation, it’s always a good practice to ensure your system is up-to-date with the latest security patches and bug fixes. Open a terminal and execute the following commands:

sudo apt update
sudo apt upgrade

The apt update command refreshes the package lists, ensuring you have access to the latest available packages. The apt upgrade command then upgrades all installed packages to their newest versions. If a new kernel version is installed, you may need to reboot your system for the changes to take effect.

Step 2: Installing Dependencies.

Nagios requires several dependencies to be installed before we can proceed with the main installation. Run the following command to install the necessary packages:

sudo apt install autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php libgd-dev libssl-dev -y

Step 3. Create Nagios User and Group

Nagios requires a dedicated user and group for running its processes and managing permissions. Execute the following commands to create the necessary user and group:

sudo useradd -m -s /bin/bash nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data

Step 4. Installing Nagios on Ubuntu 24.04.

Now it’s time to download and compile the Nagios Core from source. Follow these steps:

curl -L -O https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-4.5.2/nagios-4.5.2.tar.gz

Extract the downloaded archive:

tar -xvf nagios-4.5.2.tar.gz

Change to the extracted source directory:

cd nagios-4.5.2

Configure Nagios Core with the Apache configuration directory:

./configure --with-httpd-conf=/etc/apache2/sites-enabled

Compile Nagios Core:

make all

Install the compiled binaries, initialization script, and set the appropriate permissions:

sudo make install
sudo make install-init
sudo make install-daemoninit
sudo make install-commandmode

These commands install the Nagios binaries, the initialization script for starting and stopping Nagios, and set the necessary permissions for running Nagios commands.

Step 5. Configure Apache for Nagios Web Interface.

Nagios comes with a web interface that allows you to monitor and manage your infrastructure from a user-friendly web-based interface. To set up the web interface, follow these steps:

Install the Nagios web configuration:

sudo make install-webconf

Enable the Apache rewrite and CGI modules:

sudo a2enmod rewrite
sudo a2enmod cgi

Create a password for the Nagios web interface admin user:

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

This command creates a new password file (/usr/local/nagios/etc/htpasswd.users) and prompts you to enter a password for the “nagiosadmin” user. This user will be used to access the Nagios web interface.

Restart the Apache web server:

sudo systemctl restart apache2

With these steps completed, you’ve successfully configured Apache to serve the Nagios web interface.

Step 6. Download and Install Nagios Plugins.

Nagios Plugins are essential for monitoring various aspects of your IT infrastructure. They are separate from the Nagios Core and need to be installed separately. Follow these steps to install the Nagios Plugins:

sudo apt install autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext

Download the latest stable release of Nagios Plugins:

curl -L -O https://github.com/nagios-plugins/nagios-plugins/releases/download/release-2.4.10/nagios-plugins-2.4.10.tar.gz

Extract the downloaded archive:

tar -xvf nagios-plugins-2.4.10.tar.gz

Change to the extracted source directory:

cd nagios-plugins-2.4.10

Configure and install the Nagios Plugins:

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install

With the Nagios Plugins installed, you now have a wide range of monitoring capabilities at your disposal, including checks for various services, system resources, and network components.

Step 7. Configure Nagios.

Now that you’ve installed Nagios Core and the necessary plugins, it’s time to configure Nagios to monitor your infrastructure. Follow these steps:

sudo nano /usr/local/nagios/etc/nagios.cfg

Uncomment the line that starts with cfg_dir=/usr/local/nagios/etc/servers by removing the leading #. This line tells Nagios where to find the configuration files for the hosts and services you want to monitor.

Create the servers directory:

sudo mkdir /usr/local/nagios/etc/servers

Configure the contact information for receiving notifications:

sudo nano /usr/local/nagios/etc/objects/contacts.cfg

In this file, you’ll define the contact details (e.g., email addresses) for receiving notifications when issues are detected.

Validate the Nagios configuration:

sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

With Nagios installed and configured, it’s time to start the service and access the web interface:

sudo systemctl start nagios

Enable Nagios to start automatically on system boot:

sudo systemctl enable nagios

Step 8. Access the Nagios Web Interface.

Access the Nagios web interface by navigating to http://SERVER_IP/nagios in your web browser, replacing SERVER_IP with the IP address or hostname of your Ubuntu 24.04 server.

Log in to the Nagios web interface using the “nagiosadmin” user and the password you set earlier. After logging in, you should see that Nagios is monitoring the localhost by default. You can now start configuring Nagios to monitor your other hosts and services.

Install Nagios on Ubuntu 24.04 LTS Noble Numbat

Congratulations! You have successfully installed Nagios. Thanks for using this tutorial for installing the Nagios open-source monitoring solution on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the Nagios website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button