How to install Monit monitoring program on HestiaCP? Detailed explanation of Monit installation method

The shocking truth: Why aren't you here yet? HestiaCP How to install Monit on Linux?

Now let's talk about why Monit is one of the best partners for HestiaCP users.

Monit allows you to easily monitor key server services, such as Nginx, PHP-FPM and MySQL.

Moreover, you can integrate Monit into your HestiaCP in just a few simple steps, just as easy as spreading butter on bread. Are you ready? Let's get started!

What is Monit and why is it so important to HestiaCP?

Before we dive into the tutorial, let's take a brief look at Monit. Monit is a lightweight open source tool that can monitor processes and services in Unix systems.

If a process dies, Monit can automatically restart it, ensuring your server always remains up and running.

It's like having a 24/7 bodyguard for your server that's not only reliable but also responsive.

Prerequisites for installing Monit on HestiaCP

Before installing Monit, please make sure you have the following:

  • Hestia Control Panel installed
  • Have root access

If you meet these criteria, then we can proceed.

Step 1: Update system packages

First, make sure your system packages are up to date. Use the following command to update your system packages:

apt update

This is very important, as system package updates can fix potential vulnerabilities and ensure that your Monit installation is the latest version.

Step 2: Install Monit

After the system update is complete, you can install Monit. Enter the following command to install it:

apt install monit

This step will automatically download and install Monit. You just need to wait patiently for a few minutes.

Step 3: Enable Monit service

Once the installation is complete, don't forget to enable the Monit service so that it automatically runs at system boot. Use the following command to enable the service:

systemctl enable monit

This is like installing a pair of automatic wheels for Monit, so that it will start automatically whenever you restart the server.

Step 4: Start the Monit service

Next, start the Monit service to put it to work:

systemctl start monit

Now that Monit is running in the background, it is ready to monitor your services.

Step 5: Configure Monit

Monit's default configuration may not be suitable for all environments, so we need to make some adjustments. /etc/monit/monitrc file and add the following content:

set httpd port 2812 and
  use address 0.0.0.0
  and allow localhost

check process nginx with pidfile /var/run/nginx.pid
  group nginx
  start program = "/etc/init.d/nginx start"
  stop program = "/etc/init.d/nginx stop"

check process php-fpm with pidfile /var/run/php/php7.4-fpm.pid
  group php-fpm
  start program = "/etc/init.d/php7.4-fpm start"
  stop program = "/etc/init.d/php7.4-fpm stop"

check process mysql with pidfile /var/run/mysqld/mysqld.pid
  group mysql
  start program = "/etc/init.d/mysql start"
  stop program = "/etc/init.d/mysql stop"

This configuration code does several things:

  1. Enable Monit's web interface, you can pass http://your_server_ip:2812 access it.
  2. Monitor Nginx, PHP-FPM and MySQL Services, making sure they are always online.

Step 6: Set up the Monit service to start automatically at boot

Enter the following command

systemctl enable monit
systemctl start monit
  • If the error message "sudo systemctl start monitmonit.service is not a native service, redirecting to systemd-sysv-install.", please click the article link below to view the solution▼

Step 7: Restart the Monit service

After the configuration is complete, don't forget to restart the Monit service for the configuration to take effect:

systemctl restart monit

It’s like breathing new life into Monit, and it’s now ready to shine.

How to verify that Monit was installed successfully?

After the installation is complete, open your browser and visit http://your_server_ip:2812, you should see the Monit dashboard.

If everything goes well, you should see the status of Nginx, PHP-FPM, and MySQL.

Their status is displayed as "Running", indicating that they are running normally.

If any of these processes stop running, Monit will automatically try to restart them.

How to reinstall Monit

If you find that your Monit installation has problems, or needs to be reconfigured, you can reinstall Monit using the following command:

apt-get remove monit
apt-get install monit

Enable port 2812: Make sure you can access Monit's web interface

To ensure that Monit's web interface can be accessed normally, you need to enable port 2812.

On monitrc In the file, make sure that the HTTPD listener is set up and that port 2812 and the correct IP address are specified.

Enable port 2812 in HestiaCPCP

Once you have successfully installedMonit monitoring, you need to set up the daemon, enable ports, IP addresses and other settings.

Step 1:Log in to your HestiaCPCP

Step 2:Enter the firewall.

  • Click "Firewall" above the navigation.

Step 3:Click the + button.

  • When you hover over the + button, you'll see the button change to "Add Rule".

Step 4:Add rules.

Use the following as rule settings ▼

  • Action: Accept
  • Protocol: TCP
  • Port: 2812
  • IP address: 0.0.0.0/0
  • Remarks (optional): MONIT

Below is a screenshot of the HestiaCP firewall settings ▼

How to install Monit monitoring program on HestiaCP? Detailed explanation of Monit installation method

Conclusion: The perfect combination of Monit and HestiaCP

At this point, you should have successfully installed and configured Monit on HestiaCP.

It will become your right-hand man in server management, ensuring the normal operation of all critical services.

Moreover, Monit's web interface allows you to easily monitor the status of all processes, so everything is under control.

let's move!Configure Monit for your server now to improve its stability and reliability. Your future self will thank you for this wise decision.

Comment

Your email address will not be published. Required fields * Callout

Scroll to Top