How to Install Nagios 4.3 on an AWS Ubuntu 16 EC2 Instance

The purpose of this guide is to outline the steps required to install Nagios 4.3.2 on an AWS Ubuntu 16 EC2 Instance. The result of the performed steps will be a unique AWS VPC containing a new EC2 instance using an Ubuntu 16 operating system. The instance will have Nagio’s 4.3.2 installed with the web console accessible ready to start monitoring other AWS EC2 instances. 

The implementation notes are currently in point form and can be followed in the order they appear. We will continue to iterate on the format of this guide based on feedback from readers.

Example Nagios / AWS Architecture 

  • AWS VPC – company-vpc-01
    • AWS Security Group – sec-group-01
      • EC2 Instance – nagios-ec2-01
        • Elastic IP
        • Snap storage volume
        • Ubuntu 16 OS
          • Apache Service
          • Nagios 4.3.2 Service

Implementation Steps

  • Login to AWS, create new VPC or use existing VPC based on your requirements.
  • Create new security group, or use existing security group. Add the following inbound rules.
    • Note: These rules are relevant for a “test” or “sandbox” environment. For production environments please consult AWS Security Group best practices. 

AWS inbound rules nagios

  • Launch new ec2 instance.
  • Select Ubuntu Server 16.04 LTS (HVM), SSD Volume Type – ami-b3d965d7
  • Select t2.micro as instance type (optional). 
  • Configure instance details.
    • Change VPC
    • Auto Assign Public IP: Enable
  • Add storage.
    • Leave as default (8GB)
  • Add existing security group (created previously).
  • Review and Launch Instance. 
  • Create new key pair
    • my-key-vpc-01
    • Download key .pem file and place in client documentation folder.
    • Create private key using .pem file and puttyGen.
  • Navigate to EC2 instance list
  • Change name of node to desired name. ex. nagios-node-01
  • Go to node details and assign an elastic IP. This will give your Nagios server an assigned IP so it doesn’t change on restart / reboot. 
    • Allocate new IP address
    • Associate to nagios-node-1
    • Select default private IP
  • Login to newly created EC2 instance using private key, username and password.
  • Once logged in, run the following commands, in order.
      • sudo apt-get update
      • sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.0 libgd2-xpm-dev
      • Cd /tmp
      • sudo wget -O nagioscore.tar.gz
      • sudo tar xzf nagioscore.tar.gz
      • cd /tmp/nagioscore-nagios-4.3.2/
      • sudo ./configure –with-httpd-conf=/etc/apache2/sites-enabled
      • sudo make all
      • sudo useradd nagios
      • sudo usermod -a -G nagios www-data
      • sudo make install
      • sudo make install-init
      • sudo update-rc.d nagios defaults
      • sudo make install-commandmode
      • sudo make install-config
      • sudo make install-webconf
      • sudo a2enmod rewrite
      • sudo a2enmod cgi
      • sudo ufw allow Apache
      • sudo ufw reload
      • sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
      • sudo systemctl restart apache2.service
      • sudo systemctl start nagios.service
  • Test Nagios Web Interface using the elastic IP assigned to the node.
    • Example:
    • default login: username = nagios / password = nagiosadmin

At this point in time your Ubuntu EC2 instance is deployed with a fresh installation of Nagios 4.3.2 that can be accessed via the web console. You can install basic Nagios plugins logging into the Ubuntu EC2 instance and running the following additional commands.

Now restart both the Apache and Nagios services for the plugin to activate the installed plugins.

  • sudo systemctl restart apache2.service
  • sudo systemctl start nagios.service

You should now have Nagios 4.3.2 and plugin package 2.2.1 installed on your Ubuntu AWS EC2 instance. Once your initial installation is complete you will want to begin modifying your Nagios config to monitor and alert on the health and performance metrics of nodes in your environment.

If you found this article valuable or have feedback and/or questions please leave a comment below or email

Leave a Comment