How to Install Nagios Server on Ubuntu Linux

|

|

This tutorial illustrates the steps to install and configure Nagios, a system that monitors networks, hardware, servers, and other web-connected devices, on Ubuntu servers. The guide includes the installation of Apache2 and PHP packages, the creation of a Nagios server, and the following basic configuration. It concludes with the user logging onto the Nagios server…

This brief tutorial shows students and new users how to install and configure the Nagios monitoring server on Ubuntu 16.04 | 17.10 | 18.04 LTS servers.

Nagios is a powerful tool that helps monitor networks, servers, and other connected devices. By installing Nagios on Ubuntu Linux, you can centrally monitor the health of your network and quickly identify and resolve issues.

Ubuntu is a popular and stable Linux distribution widely used in server environments, making it an excellent choice for running Nagios. Additionally, Ubuntu makes it easy to install and configure Nagios with its built-in package manager and user-friendly interface.

Overall, installing Nagios on Ubuntu Linux is a straightforward process that can help you maintain the health and stability of your IT infrastructure.

For more about Nagios, please visit its homepage.

When you’re ready, continue below with the steps:

Install Apache2

Before installing Nagios server packages, ensure the Apache2 HTTP server is installed. To do that on Ubuntu, run the commands below.

sudo apt update
sudo apt install apache2

Install PHP Packages

Nagios server also requires that PHP and related modules be installed. If you don’t have these, it will automatically install them when you run the commands to install Nagios. For example, the commands below install PHP and related packages.

sudo apt install php php-cgi libapache2-mod-php php-common php-pear php-mbstring

Install Nagios Server Packages

To get Nagios on Ubuntu systems, run the commands below. The commands also include an essential plugin to monitor the Nagios server itself.

sudo apt install nagios3 nagios-plugins-basic

When you run the above command, you’ll be prompted to create a password for nagiosadmin account.

  ┌─────────────────────────────────────────────────┤ Configuring nagios3-cgi ├─────────────────────────────────────────────────┐
  │ Please provide the password to be created with the "nagiosadmin" user.                                                      │ 
  │                                                                                                                             │ 
  │ This is the username and password you will use to log in to your nagios installation after configuration is complete.  If   │ 
  │ you do not provide a password, you will have to configure access to nagios yourself.                                        │ 
  │                                                                                                                             │ 
  │ Nagios web administration password:                                                                                         │ 
  │                                                                                                                             │ 
  │ ___________________________________________________________________________________________________________________________ │ 
  │                                                                                                                             │ 
  │                                              <Ok>                                                                           │ 
  │                                                                                                                             │ 
  └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ 

Create one and continue.

Configure Nagios Server

Once the Nagios server is installed, run the commands below to open its default configuration file.

sudo nano /etc/nagios3/nagios.cfg

Then, make the highlighted changes below and save the file.

# EXTERNAL COMMAND OPTION
# This option allows you to specify whether or not Nagios should check
# for external commands (in the command file defined below).  By default
# Nagios will *not* check for external commands, just to be on the
# cautious side.  If you want to be able to use the CGI command interface
# you will have to enable this.
# Values: 0 = disable commands, 1 = enable commands

check_external_commands=1

Next, run the commands below to open the Nagios Apache2 config file.

sudo nano /etc/nagios3/apache2.conf

Then limit access from the localhost and local subnet only.

# nagios 1.x:
#Alias /nagios /usr/share/nagios3/htdocs

<DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
        Options FollowSymLinks
        DirectoryIndex index.php index.html
        AllowOverride AuthConfig
    
   <IfVersion < 2.3>
       Order Allow,Deny
       Allow From localhost 10.0.0.0/24
   </IfVersion>

Save the file and continue below.

Next, run the commands below to adjust the Nagios folder permissions.

sudo chgrp -R www-data /var/lib/nagios3 
sudo root@dlp:~# chmod 750 /var/lib/nagios3/rw

After that, restart Nagios2 and Apache2.

sudo systemctl restart nagios3.service
sudo systemctl restart apache2.service

Finally, open your browser, browse the server hostname or IP address, and log on to the Nagios server.

http://localhost/nagios3

Use the username nagiosadmin and the password you created above.

That’s it!

You may also like the post below:

Like this:



5 responses to “How to Install Nagios Server on Ubuntu Linux”

  1. Grayson Peddie Avatar
    Grayson Peddie

    Because I am brand new to using Nagios, how do I add a host?

  2. lev Avatar
    lev

    in “sudo root@dlp:~# chmod 750 /var/lib/nagios3/rw” typo I guess “root@dlp:~#”

    1. zodithx Avatar
      zodithx

      That name is that of the tutorial machine, and it means that you use sudo for that command

  3. Saeed Avatar
    Saeed

    Help pls, i dont understand. Does this tutorial require you to install the nagios on ubuntu server only or you’ll have to switch to desktop ubuntu after the restarting step?

  4. Martinien MAMENE Avatar
    Martinien MAMENE

    merci beaucoup a vous j’ai respecter les étapes et ça marche

Leave a Reply to Martinien MAMENE Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.