How to Install Nagios on Ubuntu 24.04
Complete guide to install Nagios on Ubuntu 24.04 LTS from source with Nagios Core, official plugins, Apache web console, and basic auth security.

6 min read
Complete guide to install Nagios on Ubuntu 24.04 LTS from source with Nagios Core, official plugins, Apache web console, and basic auth security.
- Prerequisites and Supported Releases
- Step 1: Installing Compilation Toolchains and Prerequisites
- Step 2: Creating Dedicated User and Group Accounts
Proactive infrastructure observability is essential for maintaining high availability across enterprise servers, private clouds, and production networks. When you install nagios on ubuntu 24.04, you deploy a robust monitoring daemon that periodically checks system metrics—including CPU load, memory utilization, disk space, and daemon states—and alerts administrators before outages impact end users.
While older Linux distributions packaged outdated Nagios binaries in generic repositories, compiling Nagios Core directly from official source tarballs on Ubuntu 24.04 ensures that you run the latest release with updated security patches, modern glibc compatibility, and optimized GCC compiler flags. Combining the core engine with the official Nagios Plugins suite provides immediate monitoring coverage for HTTP, SSH, SMTP, ping, and database ports.
In this step-by-step guide, you will learn how to prepare Ubuntu 24.04 with necessary build toolchains, create dedicated service users and groups, compile and install Nagios Core, configure Apache virtual hosts with basic authentication, build the official Nagios Plugins, and access the web management dashboard.
Nagios Core is an industry-standard, open-source infrastructure monitoring and alerting engine capable of tracking servers, switches, network services, and applications across enterprise environments. This comprehensive tutorial details how to install Nagios on Ubuntu 24.04 LTS by compiling Nagios Core 4.x and the official Nagios Plugins from verified source tarballs, configuring the Apache HTTP server web console, securing administrative logins with HTTP basic authentication, and verifying daemon service health.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A server running Ubuntu 24.04 LTS with at least 1 GB RAM and 10 GB storage.
- A non-root user account with active sudo administrative privileges.
- A command-line terminal with stable Internet connectivity.
- Basic familiarity with executing compilation commands (
make,gcc).
Step 1: Installing Compilation Toolchains and Prerequisites
Compiling Nagios Core and its graphical CGI web modules requires build utilities (build-essential), Apache web server, PHP, graphics libraries (libgd-dev), and cryptographic development headers.
Refresh your APT package database and install the complete development prerequisites.
# Refresh package repository index
sudo apt update && sudo apt upgrade -y
# Install build tools, Apache, PHP, and graphics libraries
sudo apt install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php \
libgd-dev libssl-dev libmcrypt-dev bc gawk dc build-essential
Step 2: Creating Dedicated User and Group Accounts
To enforce the principle of least privilege, Nagios should never run as the root superuser. Create a dedicated system user and group named nagios.
Additionally, create an external command group named nagcmd and add both the nagios service user and the Apache web server user (www-data) to this group. This allows the Apache CGI scripts to submit command requests to the Nagios core daemon.
# Create dedicated nagios user and group
sudo useradd nagios
sudo groupadd nagcmd
# Add nagios and www-data to the nagcmd group
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data
Step 3: Downloading and Extracting Nagios Core Source Code
Download the latest stable Nagios Core source release tarball directly from the official GitHub releases portal into your temporary directory.
Extract the archive and navigate into the source directory.
# Navigate to /tmp directory
cd /tmp
# Download Nagios Core source tarball
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.5.2.tar.gz
# Extract the archive
tar -zxvf nagios-4.5.2.tar.gz
# Enter extracted directory
cd nagios-4.5.2
Step 4: Compiling and Installing Nagios Core
Initialize the source configuration script by specifying the command group (nagcmd). Once configuration finishes, build the binaries using make all.
Next, install the main program, systemd service units, sample configuration files, and external command directory permissions using the specialized make targets.
# Configure build with command group
./configure --with-command-group=nagcmd
# Compile Nagios binaries and documentation
make all
# Install core binaries and CGIs
sudo make install
# Install systemd unit script
sudo make install-init
# Install sample configuration files in /usr/local/nagios/etc/
sudo make install-config
# Configure external command file permissions
sudo make install-commandmode
Step 5: Configuring the Apache Web Console and Authentication
Install the Apache configuration file for the Nagios web console using make install-webconf. Enable the Apache rewrite and cgi modules required by the Nagios CGI dashboard.
Next, create an administrative web user named nagiosadmin and define a secure password using htpasswd. The default Nagios sample configuration expects this username for full administrative access.
# Install Apache configuration snippet
sudo make install-webconf
# Enable Apache CGI and rewrite modules
sudo a2enmod rewrite cgi
# Create web console administrator account
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
# Restart Apache to apply new virtual host and modules
sudo systemctl restart apache2
Step 6: Compiling and Installing Official Nagios Plugins
Nagios Core functions solely as a scheduling and alerting daemon; the actual host and service health checks are performed by standalone executable plugins located in /usr/local/nagios/libexec/.
Download, compile, and install the official Nagios Plugins collection.
# Navigate back to /tmp
cd /tmp
# Download Nagios Plugins source archive
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 and compile plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install
Step 7: Validating Configuration and Starting Nagios Service
Before starting the daemon, always run the Nagios verification utility (-v) against the master configuration file /usr/local/nagios/etc/nagios.cfg. This ensures there are no syntax errors or missing directives.
Once verification reports zero warnings and zero errors, enable and start the Nagios systemd daemon.
# Validate Nagios configuration syntax
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# Enable and start Nagios service
sudo systemctl enable --now nagios
# Verify service is actively running
sudo systemctl status nagios
Step 8: Accessing and Navigating the Nagios Dashboard
Open your web browser and navigate to http://your_server_ip/nagios. Your browser will prompt you for HTTP basic authentication credentials.
Enter nagiosadmin and the password configured in Step 5. Once authenticated, the Nagios Core web console displays your monitoring overview, host states, service alerts, and performance graphs.
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
Nagios web interface shows: 'It appears as though you do not have permission to view information'
Resolution: This occurs if you created an Apache user with a name other than nagiosadmin. Edit /usr/local/nagios/etc/cgi.cfg and ensure your username is added to the authorized user parameters, or recreate the user as nagiosadmin using htpasswd.
Apache returns 404 Not Found when browsing /nagios
Resolution: Verify that the Nagios Apache configuration was loaded into /etc/apache2/sites-available/ or /etc/apache2/conf-available/nagios.conf. Enable the configuration with sudo a2enconf nagios and reload Apache with sudo systemctl reload apache2.
Plugins missing or returning 'check_ping: command not found'
Resolution: Ensure you compiled the plugins package with --with-nagios-user=nagios and ran sudo make install. Verify that executable binary files exist under /usr/local/nagios/libexec/.
Security Best Practices and Hardening
Always enforce strong passphrases on /usr/local/nagios/etc/htpasswd.users to prevent unauthorized visibility into your server infrastructure.
Deploy an SSL/TLS certificate with Let's Encrypt Certbot (sudo certbot --apache) so monitoring credentials are not transmitted in plain text.
Restrict web console access in Apache (/etc/apache2/conf-available/nagios.conf) to trusted internal administrator IP ranges using Require ip directives.
Do not run the Nagios daemon or any monitoring plugins as the root user account.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- Initial Server Setup on Ubuntu 24.04 — Configure foundational security, firewall, and sudo users on your Ubuntu environment.
- How to Configure Static IP Address on Ubuntu 24.04 — Set up persistent network interfaces for high-availability monitoring servers.
- How to Install and Configure Caddy on Ubuntu 24.04 — Explore lightweight reverse proxy alternatives for securing internal web consoles.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
/usr/local/nagios/etc/objects/ (e.g. hosts.cfg or services.cfg), reference them in nagios.cfg, verify syntax with nagios -v, and reload the service./usr/local/nagios/var/nagios.log.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides


Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!