In this tutorial, we will show you how to install Monit on Ubuntu 20.04 LTS. For those of you who didn’t know, Monit is an open-source program used to monitor services on Linux systems and ensure they are always online. Monit supervises the processes and restarts them on failure detection. Apart from the processes, Monit can also be used to monitor CPU, RAM, Disk, File Size, and trigger alerts on out-of-bound values. It also shows how to trigger alert emails using custom templates.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of Monit on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
Prerequisites
- A server running one of the following operating systems: Ubuntu 20.04, 18.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, you can harm your system if you’re not careful when acting as the root.
Install Monit on Ubuntu 20.04 LTS Focal Fossa
Step 1. First, make sure that all your system packages are up-to-date by running the following apt
commands in the terminal.
sudo apt update sudo apt upgrade
Step 2. Installing Monit on Ubuntu 20.04.
By default, Monit is available in the Ubuntu 20.04 default repository. You can install it using the following command below:
sudo apt install monit
Once installed, the Monit service will be started automatically. You can check the status of Monit with the following command:
sudo systemctl status monit
Step 3. Enable Monit HTTP interface.
By default, the Monit web interface is disabled, so you will need to enable it and set the admin password. You can do this by editing the file /etc/monit/monitrc
.
nano /etc/monit/monitrc
Uncomment and set the Monit admin password as shown below:
set httpd port 2812 and allow admin:adminpassword
Save and close the editor. Now restart Monit using the command:
sudo monit -t sudo systemctl restart monit
*The configuration file is pretty self-explaining, if you are unsure about an option, take a look at the Monit documentation.
Step 4. Accessing Monit Web Interface.
Now, open your web browser and access the Monit web interface using the URL http://your-server-ip-address:2812
. You should see the Monit login page. Log in with the username as “admin” and password as “monit”.
Congratulations! You have successfully installed Monit. Thanks for using this tutorial for installing Monit on Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official Monit website.