In this tutorial, we will show you how to install Nagios on Debian 12. Nagios is a powerful open-source monitoring solution that enables organizations to identify and resolve IT infrastructure issues. It provides real-time alerts and status overviews for servers, networks, and applications, enabling proactive problem resolution.
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 monitoring system on a Debian 12 (Bookworm).
- A server running one of the following operating systems: Debian 12 (Bookworm).
- 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 for Nagios.
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install Nagios on Debian 12 Bookworm
Step 1. 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. Installing 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 autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.4 libgd-dev
Step 3. Create a Nagios User and Group.
Create a dedicated user and group for Nagios to run securely:
sudo useradd nagios sudo groupadd nagcmd sudo usermod -a -G nagcmd nagios
These commands create a new user named ‘nagios’, a new group named ‘nagcmd’, and add the ‘nagios’ user to the ‘nagcmd’ group.
Step 4. Installing Nagios on Debian 12.
Now, download the latest version of Nagios Core from the official website and install it. Run the following commands:
wget https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-4.5.0/nagios-4.5.0.tar.gz tar xzf nagios-4.5.0.tar.gz cd nagios-4.5.0 ./configure --with-command-group=nagcmd make all sudo make install sudo make install-init sudo make install-config sudo make install-commandmode
These commands will download Nagios Core, extract the files, configure the installation, and install Nagios.
Step 5. Installing Nagios Web Interface.
To access Nagios from a web browser, you need to install the Nagios web interface. Run the following commands to install it and configure Apache to work with Nagios:
sudo make install-webconf sudo a2enmod rewrite sudo a2enmod cgi
Step 6. Create Nagios Admin User.
Create a Nagios admin user to manage the Nagios web interface. Replace ‘nagiosadmin’ with your preferred username:
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Step 7. Installing Nagios Plugins.
Nagios plugins are essential for Nagios to monitor services. Download and install the latest Nagios plugins from the official website:
cd /tmp wget https://nagios-plugins.org/download/nagios-plugins-2.4.8.tar.gz tar -zxvf nagios-plugins-2.4.8.tar.gz cd nagios-plugins-2.4.8/ ./configure --with-nagios-user=nagios --with-nagios-group=nagios make sudo make install
Finally, start the Nagios service and enable it to start on boot:
sudo systemctl start nagios sudo systemctl enable nagios
Step 8. Accessing Nagios Web Interface
Finally, you can access the Nagios web interface by navigating to
http://your_domain_or_IP/nagios in your web browser. Log in with the user ‘
nagiosadmin‘ and the password you created during the installation process.
Congratulations! You have successfully installed Nagios. Thanks for using this tutorial to install the latest version of the Nagios monitoring tool on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Nagios website.