> For the complete documentation index, see [llms.txt](https://docs.acecloud.ai/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acecloud.ai/knowledge-base/tutorials/how-to-install-nagios-on-ubuntu-20.04.md).

# How to install Nagios on Ubuntu 20.04?

{% embed url="<https://youtu.be/H7M7qqY0FkA>" %}

### Overview

Nagios is an open-source monitoring tool. It helps monitor all your network, servers, services, apps, and processes, which also keeps an inventory of your whole IT infrastructure.\
This tutorial demonstrates the installation of Nagios on Ubuntu server.

### **Prerequisites**&#x20;

There are certain prerequisites that need to be met before you begin.&#x20;

* A server running Ubuntu 20.04
* Non-root sudo user privileges

### **Get Started**

**Step 1** - Setting up Nagios on Ubuntu 20.04

* Execute the below commands as a user with sudo permissions to install Nagios:

```
sudo apt update
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1378_image-2023-4-20_15-23-44.png" alt="" height="196" width="800">

```
sudo apt install nagios4 nagios-plugins-contrib nagios-nrpe-plugin
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1379_image-2023-4-20_15-26-20.png" alt="" height="63" width="800">

* The Apache configuration file requires the mod\_auth\_digest and mod\_authz\_groupfile modules which are used to grant or restrict access to users who have provided proof of group membership. So, to enable these modules, execute the below commands:

```
sudo a2enmod authz_groupfile auth_digest
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1380_image-2023-4-19_15-9-22.png" alt="" height="70" width="800">

* Nagios can only be accessed by localhost and private IP addresses under the default configuration of Apache.  We will now modify the configuration so that only the users who have been authenticated will be able to view the interface and run commands.

```
sudo nano /etc/apache2/conf-enabled/nagios4-cgi.conf
```

* Locate the lines beginning with "Require ip" and "Require all granted" and comment them. Next, navigate to the line "Require valid-user" and uncomment it, as shown below:

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1381_image-2023-4-19_15-22-14.png" alt="" height="350" width="800">

* Once you are done with the modifications, restart Apache:

```
sudo systemctl restart apache2
```

* By examining their status, you can confirm that Nagios and Apache are both operating correctly:

```
sudo systemctl status apache2
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1382_image-2023-4-19_15-33-17.png" alt="" height="126" width="800">

```
sudo systemctl status nagios4
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1383_image-2023-4-19_15-41-42.png" alt="" height="127" width="800">

Press q or Ctrl+z to exit.

**Step 2** - Setting Up a User Account

* By default, Nagios is set up to give the user "nagiosadmin" administrative rights. You can access the Nagios web interface and control your inventory using this user. To create the user, enter the following htdigest command:

```
sudo htdigest -c /etc/nagios4/htdigest.users Nagios4 nagiosadmin
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1384_image-2023-4-19_15-51-50.png" alt="" height="33" width="800">

* To make modifications effective, restart the Apache service:

```
sudo systemctl restart apache2
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1385_image-2023-4-19_15-56-15.png" alt="" height="13" width="800">

**Step 3** - Setting Up the Firewall&#x20;

* UFW firewall setup software is included in Ubuntu. Ensure that the HTTP/HTTPS ports are open if your system has a firewall enabled:

```
sudo ufw allow Apache
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1386_image-2023-4-19_16-2-39.png" alt="" height="24" width="800">

**Step 4** - Getting to the Nagios Web Interface

* Open your preferred browser and enter your IP address, and then type /nagios (version number) to access the Nagios web interface:

```
http(s)://your_domain_or_ip_address/nagios4
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1387_image-2023-4-19_16-6-20.png" alt="" height="396" width="800">

### **Conclusion**&#x20;

We have successfully demonstrated how to set up Nagios on Ubuntu system.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.acecloud.ai/knowledge-base/tutorials/how-to-install-nagios-on-ubuntu-20.04.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
