In this tutorial we are going to learn how to install Monit on Ubuntu 18.04. We will also install and configure its prerequisites. Monit is a small open source utility that has been developed to manage and monitor Unix systems. When using the Monit application, it is responsible for carrying out maintenance and automatic repair of failed processes and is in the ability to execute management actions in error situations to maintain the operability of the operating system.
I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 18.04 LTS Bionic Beaver minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install Monit on Ubuntu 18.04
Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:
apt-get update -y apt-get upgrade -y
Step 2. Install Monit on Ubuntu 18.04 Bionic Beaver.
To install Monit in Ubuntu, we will execute the following command:
sudo apt install monit
To start the process, use systemctl command available on Ubuntu 18.04:
sudo systemctl start monit sudo systemctl enable monit
Step 3. Configure Monit in Ubuntu.
We will access the main configuration directory using any of the desired editors:
Set the mail server information for relaying the alerts generated by Monit:
set mailserver mx.myvpsource.com port 25
Specify an email address on which you want to be alerted in case of any failures/events:
set alert email@example.com
Step 4. Enable Monit Web Interface.
By default, Monit web interface is disabled. To enable, edit the Monit configuration file “/etc/monit/monitrc“:
Look for “set httpd port 2812” line and change the following entries:
set httpd port 2812 and allow admin:monit # require user 'admin' with password 'monit'
Then, restart the Monit service:
systemctl restart monit
Step 5. Accessing Monit Web Interface.
Access the web interface by using below URL, and You need to use the username as “admin” and password as “monit” to access the Monit’s web interface:
Congratulation’s! You have successfully install and configured Monit on your Ubuntu 18.04 server. Thanks for using this tutorial installing Monit on Ubuntu 18.04 LTS (Bionic Beaver) system.