How to Install Zabbix on Rocky Linux and AlmaLinux

Proper monitoring is an essential ingredient for the effective management of your overall IT infrastructure. A robust real-time monitoring solution provides detailed visibility of your network and application performance.

It helps to identify actual moments when errors and incidents occur and sends alerts. By doing so, operation teams can take intervention measures in a timely fashion and ensure business continuity in the shortest time possible.

This helps you make the most of your IT resources and, in turn, maximize your revenue. As such, one cannot undermine the importance of investing in an efficient and reliable monitoring tool.

Zabbix is a free and open-source enterprise-grade monitoring tool that is used for monitoring your entire IT infrastructure. It can monitor anything including network devices, servers (cloud and on-premise) applications, databases, and even docker containers. It also detects errors and sends alerts to enable prompt action by IT teams to resolve the problem.

In this guide, we will focus on the installation of the Zabbix monitoring tool on Rocky Linux / AlmaLinux. At the time of writing this guide, the latest version of Zabbix is Zabbix 6.0 pre-release.

Prerequisites

For this guide, this is what you need to have:

Step 1: Install LAMP in Rocky/Alma Linux

Zabbix is a monitoring application that is driven by PHP on the frontend and Java & C in the backend. It also requires a relational database to collect and store its data. As such we need to install a hosting stack on which we will install Zabbix.

LAMP, short for Linux, Apache, MariaDB/MySQL, and PHP is a big household name in developer circles. It comprises the Apache webserver, MariaDB or MySQL (relational databases), and PHP which is a server-side scripting engine.

Installing Apache in Rocky/Alma Linux

We will start off by installing the Apache webserver. To do so, execute the command:

$ sudo dnf install @httpd

Once installed, start Apache and enable it to run on system startup.

$ sudo systemctl start httpd
$ sudo systemctl enable httpd

To verify that Apache is running, execute the command:

$ sudo systemctl status httpd
Check Apache Status
Check Apache Status

The output confirms that Apache is installed and running as expected.

Installing MariaDB in Rocky/Alma Linux

As mentioned earlier, Zabbix requires a relational database to store all of its data. We have chosen to install MariaDB given its reliability and numerous security and performance enhancements it provides.

The latest version of Zabbix requires MariaDB version 10.5 to function as expected. To get started, you need to enable the MariaDB YUM repository.

So, create a repository file:

$ sudo vim  /etc/yum.repos.d/mariadb.repo

Paste the following lines.

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/rhel8-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
module_hotfixes=1

Save the changes and exit the configuration file.

Next, import the MariaDB GPG signing key:

$ sudo --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

Finally, to install the MariaDB server and client, run the command:

$ sudo dnf install MariaDB-server MariaDB-client

When the installation is complete, start the MariaDB server and enable it so that it starts automatically on boot.

$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb

Confirm that the database server is running:

$ sudo systemctl status mariadb
Check MariaDB Status
Check MariaDB Status

To confirm the version of MariaDB installed, run the command:

$ mysql -V

Alternatively, you can log in to the database server as follows.

$ sudo mysql -u root -p

The version of MariaDB will be printed on the welcome message.

Check MariaDB Version
Check MariaDB Version

Typically, MariaDB’s settings are not configured to the required security recommendations. Thankfully, MariaDB provides the mysql_secure_installation script for enhancing the security of the database server.

So, execute the script as shown.

$ sudo mysql_secure_installation

You will be required to perform a list of tasks. First, switch to the UNIX socket authentication plugin.

MariaDB Unix Socket
MariaDB Unix Socket

For the remaining prompts, type 'Y' and hit ENTER. This allows you to remove anonymous users, disallow remote users from logging in as root and remove the test database which can be exploited by hackers. Then finally reload privilege tables to save changes.

Secure MariaDB Installation
Secure MariaDB Installation

The UNIX_socket authentication plugin allows the root user to log in to the database server without a password. To enable MariaDB password authentication, log in to MariaDB:

$ sudo mysql -u root -p

Then set the root password as follows.

set password = password("yourpassword");

To switch from UNIX socket authentication to mysql_native_password authentication, run the command

ALTER USER [email protected] IDENTIFIED VIA mysql_native_password USING PASSWORD("yourpassword");

Now every time you login back in, you will be required to provide a password.

Installing PHP in Rocky/Alma Linux

The last component of the LAMP stack to install is PHP. This is provided in the default AppStream repositories. You can verify this as follows:

$ sudo dnf module list PHP

By default, PHP 7.2 is enabled by default. We need to change this to PHP 7.4.

$ sudo dnf module reset php
$ sudo dnf module install php:7.4

Next, install the required PHP modules for Zabbix installation.

$ sudo dnf install php php-curl php-fpm php-mysqlnd

To check the version of PHP, run.

$ php -v
Check PHP Version
Check PHP Version

We have installed PHP-FPM (FastCGI Process Manager) service which is a popular alternative implementation of PHP FastCGI.

Start and enable it on boot time.

$ sudo systemctl start php-fpm
$ sudo systemctl enable php-fpm

Then verify its status.

$ sudo systemctl status php-fpm
Check PHP-FPM Status
Check PHP-FPM Status

At this point, we have successfully installed the LAMP stack. In subsequent steps, will delve into the installation of Zabbix.

Step 2: Install Zabbix in Rocky/Alma Linux

With the LAMP stack in place, Let’s now install Zabbix by installing the Zabbix repository.

$ sudo rpm -Uvh https://repo.zabbix.com/zabbix/5.5/rhel/8/x86_64/zabbix-release-5.5-1.el8.noarch.rpm

Once the repository is installed, install the Zabbix server, Zabbix agent, and the associated Zabbix packages as follows.

$ sudo dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

When the installation is complete, you need to create a Zabbix database and a database user that Zabbix will use to access the database.

$ sudo mysql -u root -p
CREATE USER [email protected] IDENTIFIED BY '[email protected]';

Then grant permissions to the database user to execute all tasks on the database.

GRANT ALL PRIVILEGES ON zabbix_db.* TO [email protected];

Then effect the changes and exit the database server

FLUSH PRIVILEGES;
EXIT;
Create Zabbix Database
Create Zabbix Database

Next, import the database schema:

$ sudo zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -u zabbix_user -p zabbix_db

When prompted for a password, provide the Zabbix user’s password and not the root account’s password.

Additionally, edit the Zabbix configuration file

$ sudo vim /etc/zabbix/zabbix_server.conf

Ensure that the DBName, DBUser, DBPassword values reflect the values you provided for your database

DBHost=localhost
DBName=zabbix_db
DBUser=zabbix_user
[email protected]

Save the changes and exit the configuration file.

Step 3: Configure PHP-FPM in Rocky/Alma Linux

Next, some additional configuration is needed for the PHP-FPM service. Edit the www.conf configuration file.

$ sudo vim /etc/php-fpm.d/www.conf 

Ensure that the following lines appear as they are.

listen = /run/php-fpm/www.sock
 
user = apache
group = apache

listen.allowed_clients = 0.0.0.0
listen.owner = apache
listen.group = apache
listen.mode = 0660
pm = dynamic

Save the changes and exit the file.

Additionally, specify the timezone setting in the Zabbix.conf configuration file.

$ sudo vim /etc/php-fpm.d/zabbix.conf

Add the line shown.

php_value[date.timezone] = Africa/Nairobi

Save and exit.

To apply all the changes made, restart all the services as shown

$ sudo systemctl restart zabbix-server zabbix-agent httpd php-fpm

Additionally, consider enabling them on startup.

$ sudo systemctl enable zabbix-server zabbix-agent httpd php-fpm

Step 4: Configure SELinux & Firewall in Rocky/Alma Linux

You need to set SELinux to permissive in order to access the frontend from a browser. To do that, run the command:

$ sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config

Next, head over to the firewall and allow HTTP service along with ports 10050 and 10051 which Zabbix server and agent listen on.

$ sudo firewall-cmd --add-port=80/tcp --permanent
$ sudo firewall-cmd --add-port={10050,10051}/tcp --permanent
$ sudo firewall-cmd --reload

Step 5: Complete Zabbix Installation in Rocky/Alma Linux

Lastly, launch your browser, and go to the URL shown

http://server-ip/zabbix

The first page that greets you is the Zabbix welcome page that boldly displays the version you are installing. Select the installation language and click on the ‘Next step’ button.

Zabbix Web Installer
Zabbix Web Installer

In the list of prerequisites, scroll all the way down and ensure all the prerequisites get the ‘OK’ label in the last column. It’s mandatory that all the requirements are satisfied. Then hit the ‘Next step’ button.

Zabbix Pre-Requisites Checks
Zabbix Pre-Requisites Checks

On the ‘Configure DB Connection’ page. Fill out your database details. For the database port, leave it at 0. The press ‘Next step’.

Zabbix Database Settings
Zabbix Database Settings

Then specify your server’s name, confirm your time zone and feel free to select your preferred theme. Then press ‘Next step’.

Zabbix Server Details
Zabbix Server Details

Confirm all the settings and if all looks well, press on ‘Next step’ to finalize the installation.

Zabbix Pre-installation Summary
Zabbix Pre-installation Summary

If all the settings you provided are correct, you will get a congratulatory message notifying you of the successful setup of Zabbix’s front end. Press on the ‘Finish’ button.

Zabbix Installation Complete
Zabbix Installation Complete

This directs you to the Zabbix login page. Log in with the following credentials:

Admin:	Admin
Password:   zabbix

Then click on ‘Sign in’ to access the Zabbix dashboard. You can change the password later for added security, so don’t worry about that.

Zabbix Login
Zabbix Login

Finally, you will get access to Zabbix’s dashboard.

Zabbix Dashboard
Zabbix Dashboard

And there you have it. We have successfully installed the Zabbix monitoring tool on Rocky Linux / AlmaLinux.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.