Install Nagios 4 on Ubuntu and Debian 8
Updated by Edward Angert Contributed by Paulo Telles
A monitoring tool is a key application in a production server. Nagios is a popular tool that provides monitoring and alerting services for your servers, applications and services. Using Nagios and a wide variety of available plugins, you can keep track of the status of your critical services like HTTP, SSH and SMTP. In this guide, you’ll learn how to install Nagios 4 on your Linode.
Before You Begin
In order to run Nagios on your Linode, follow the configuration steps for Ubuntu or Debian 8 from our Getting Started guide.
sudo apt-get update && sudo apt-get upgrade
NoteThis guide is written for a non-root user. Commands that require elevated privileges are prefixed with
sudo. If you’re not familiar with the
sudocommand, you can check our Users and Groups guide.
Create Users and Groups
Create a user,
nagios, and a distinct group,
nagios and the Apache user,
www-data, to the
nagcmd group in order to run external commands on Nagios through the web interface:
sudo useradd nagios sudo groupadd nagcmd sudo usermod -a -G nagcmd nagios && sudo usermod -a -G nagcmd www-data
Build Nagios 4 from Source Code
The latest stable version of Nagios 4 is not available in Ubuntu or Debian’s default repositories as of this writing. To install Nagios, download and install it from the source code:
sudo apt-get install build-essential unzip openssl libssl-dev libgd2-xpm-dev xinetd apache2-utils
In your web browser, go to the Nagios Core DIY download page. If you prefer not to register for updates, click Skip to download.
Under Nagios Core, find the release that says Latest stable release under Notes, then copy the download link to your clipboard.
Download and extract Nagios to your Linode using
tar, pasting the link from Step 3:
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz tar -xvf nagios-4.*.tar.gz
Move to the newly created directory:
Configure, compile and install Nagios:
./configure --with-nagios-group=nagios --with-command-group=nagcmd make all sudo make install sudo make install-init sudo make install-config sudo make install-commandmode
Prepare Apache and Configure Nagios Web Interface
Make sure Apache has
sudo a2enmod rewrite && sudo a2enmod cgi
Copy the sample virtual host configuration Nagios provides to
sudo cp sample-config/httpd.conf /etc/apache2/sites-available/nagios4.conf
sudo chmod 644 /etc/apache2/sites-available/nagios4.conf
Enable the new virtual host:
sudo a2ensite nagios4.conf
The web interface requires login. Create a
nagiosadminaccount and record the password you assign:
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo service apache2 restart
Install Nagios Plugins
Nagios Plugins allow you to monitor services like DHCP, FTP, HTTP and NTP. To use Nagios Plugins, go to the Nagios Plugins downloads page and copy the download link for the current stable release (e.g.,
Download and extract Nagios Plugins to your Linode using
tar, pasting the link you copied:
wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz tar -xvf nagios-plugins-2*.tar.gz
Change to the newly created directory, then configure, compile, and install Plugins:
cd nagios-plugins-2.* ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl make sudo make install
Access the Nagios Web Interface
Before accessing the Nagios Web Interface, start the Nagios service:
sudo service nagios start
NoteFor Ubuntu versions after 14.04, see the Systemd section below before running this step.
The interface can be accessed in your web browser by appending
/nagiosto your domain or Public IP. When prompted at login, use
nagiosadminas the user and use the password you assigned in the Configure Nagios Web Interface section.
You will be greeted with a screen like this one:
To view monitoring status, click the Hosts link in the menu on the left. This example screenshot shows an active Nagios server called
As of this guide’s publication, the Nagios build process does not create a systemd service file. In order to manage the service with systemd, create a Nagios service file for the system to load on initialization:
1 2 3 4 5 6 7 8 9 10 11 12
[Unit] Description=Nagios BindTo=network.target [Install] WantedBy=multi-user.target [Service] User=nagios Group=nagios Type=simple ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
Enable the link, start the Nagios service, and check the status:
sudo systemctl enable /etc/systemd/system/nagios.service sudo systemctl start nagios systemctl status nagios
You can now continue at Access the Nagios Web Interface
Nagios contains numerous features that are beyond the scope of this document. Explore the Nagios administrative interface as well as the resources listed below to access more information regarding the setup and configuration of Nagios.
Congratulations on your new Nagios monitoring and notification system!
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
Join our Community
This guide is published under a CC BY-ND 4.0 license.