How to Install and Configure Zabbix Server 5 on Rocky Linux/Alma Linux 8

Zabbix is an open-source monitoring software tool for diverse IT components, including networks, servers, virtual machines and cloud services. Zabbix provides monitoring metrics, among others network utilization, CPU load and disk space consumption. Zabbix has a rich set of features to enable users to monitor more than just hosts, offering great flexibility to administrators when it comes to choosing the most suitable option for each situation.

Zabbix uses XML based template which contains elements to monitor. The backend of Zabbix is written in C programming and PHP is used for the web frontend. Zabbix can send you alertsto notify the different events and issues based on metrics and thresholds defined for your IT environment. It supports agent-based and agentless monitoring. But Zabbix agents installation can help you to get detailed monitoring e.g. CPU load, network, disk space utilization.

As of the writting of this article, the latest Zabbix version is 5.4. In this guide, we will learn how to install and configure Zabbix on Rocky Linux 8. This guide also works for other RHEL 8 based systems like Oracle Linux 8 and Alma Linux 8.

Related content:

Ensure that the server packages are up to date

Before proceeding, let us make sure that our server packages are up to date with this command:

1
sudo dnf -y update

Let us also install some common packages that we will need

1
sudo dnf install -y vim

Install Mariadb

Zabbix depends on Mysql. Mariadb is a popular Opensource relational management system. It is available in the default repositories as mariadb-server.

Install it with this command:

1
sudo dnf install -y mariadb-server

Once mariadb is installed, you can confirm the details using this command:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$ rpm -qi mariadb-server

Name        : mariadb-server
Epoch       : 3
Version     : 10.3.28
Release     : 1.module+el8.4.0+427+adf35707
Architecture: x86_64
Install Date: Mon 17 Jan 2022 12:35:21 AM UTC
Group       : Unspecified
Size        : 85968333
License     : GPLv2 with exceptions and LGPLv2 and BSD
Signature   : RSA/SHA256, Mon 31 May 2021 12:18:29 AM UTC, Key ID 15af5dac6d745a60
Source RPM  : mariadb-10.3.28-1.module+el8.4.0+427+adf35707.src.rpm
Build Date  : Sun 30 May 2021 11:56:08 PM UTC
Build Host  : ord1-prod-x86build003.svc.aws.rockylinux.org
Relocations : (not relocatable)
Packager    : infrastructure@rockylinux.org
Vendor      : Rocky
URL         : http://mariadb.org
Summary     : The MariaDB server and related files
Description :
MariaDB is a multi-user, multi-threaded SQL database server. It is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MariaDB server and some accompanying files and directories.
MariaDB is a community developed branch of MySQL.

The Service will not be started by default. Start with this command:

1
sudo systemctl start mariadb

Confirm the status with this command:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$ sudo systemctl status mariadb

● mariadb.service - MariaDB 10.3 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2022-01-17 00:36:02 UTC; 17s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 41146 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 41011 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
  Process: 40987 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 41114 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 23176)
   Memory: 80.2M
   CGroup: /system.slice/mariadb.service
           └─41114 /usr/libexec/mysqld --basedir=/usr

Jan 17 00:36:01 dev-rockysrv.citizix.com mysql-prepare-db-dir[41011]: See the MariaDB Knowledgebase at http://mariadb.com/kb or the
Jan 17 00:36:01 dev-rockysrv.citizix.com mysql-prepare-db-dir[41011]: MySQL manual for more instructions.
Jan 17 00:36:01 dev-rockysrv.citizix.com mysql-prepare-db-dir[41011]: Please report any problems at http://mariadb.org/jira
Jan 17 00:36:01 dev-rockysrv.citizix.com mysql-prepare-db-dir[41011]: The latest information about MariaDB is available at http://mariadb.org/.
Jan 17 00:36:01 dev-rockysrv.citizix.com mysql-prepare-db-dir[41011]: You can find additional information about the MySQL part at:
Jan 17 00:36:01 dev-rockysrv.citizix.com mysql-prepare-db-dir[41011]: http://dev.mysql.com
Jan 17 00:36:01 dev-rockysrv.citizix.com mysql-prepare-db-dir[41011]: Consider joining MariaDB's strong and vibrant community:
Jan 17 00:36:01 dev-rockysrv.citizix.com mysql-prepare-db-dir[41011]: https://mariadb.org/get-involved/
Jan 17 00:36:01 dev-rockysrv.citizix.com mysqld[41114]: 2022-01-17  0:36:01 0 [Note] /usr/libexec/mysqld (mysqld 10.3.28-MariaDB) starting as process 41114 ...
Jan 17 00:36:02 dev-rockysrv.citizix.com systemd: Started MariaDB 10.3 database server.

To ensure that mariadb starts on boot, enable it with this systemd command:

1
sudo systemctl enable mariadb

Once the mysql service is running, you need to secure it. Mysql provides a commandline utility that will do that:

1
sudo mysql_secure_installation

The above command will take you through prompts to secure and set a root password for the mysql instance.

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

1
2
3
$ mysql -V

mysql  Ver 15.1 Distrib 10.3.28-MariaDB, for Linux (x86_64) using readline 5.1

For more info on how to install and configure mariadb in Rocky Linux check out How to install and Configure Mariadb 10 in Rocky Linux/Alma Linux 8.

Create mysql user for Zabbix

We are going to create a dedicated user for zabbix. Check out this guide on managing mysql permissions here.

Connect to mysql server:

1
mysql -u root -p

After Supplying your root password, enter the following to the mysql prompt:

1
2
3
create database zabbix character set utf8 collate utf8_bin;
create user 'zabbix_user'@'%' identified by 'S0mStrongPa$$word';
grant all privileges on zabbix.* to 'zabbix_user'@'%';

Save the username, db name and password, we will need them later.

Now that we have configured our mysql connection, let’s go to the next section where we install and configure PHP.

Install PHP and required php modules

The default php version in Rocky Linux might be outdated. To have control over the php version, let us install the Remi release repo using this command:

1
sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm

Enable version 7.4 of php

1
sudo dnf module enable -y php:remi-7.4

You can confirm that the right version is enabled using this command:

1
sudo dnf module list php

Then install php and dependancies

Next, install the required PHP modules for Zabbix installation.

1
2
3
4
5
6
sudo dnf install -y php \
    php-cli \
    php-common \
    php-fpm \
    php-curl \
    php-mysqlnd

Check php version

1
2
3
4
5
6
$ php -v

PHP 7.4.27 (cli) (built: Dec 14 2021 17:17:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies

For more info on setting up PHP and Apache, check out this guide How to Install Apache and PHP (LAMP stack) on Rocky Linux/Centos 8

Install Apache Web Server

Next, let us install Apache in our system. Use this command to install Apache web server.

1
sudo dnf install -y httpd

Apache will be not be started by default. Start with this command:

1
sudo systemctl start httpd

Check the status using this command:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
$ sudo systemctl status httpd

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2022-01-17 00:50:15 UTC; 1s ago
     Docs: man:httpd.service(8)
 Main PID: 41791 (httpd)
   Status: "Started, listening on: port 80"
    Tasks: 213 (limit: 23176)
   Memory: 32.9M
   CGroup: /system.slice/httpd.service
           ├─41791 /usr/sbin/httpd -DFOREGROUND
           ├─41792 /usr/sbin/httpd -DFOREGROUND
           ├─41793 /usr/sbin/httpd -DFOREGROUND
           ├─41794 /usr/sbin/httpd -DFOREGROUND
           └─41795 /usr/sbin/httpd -DFOREGROUND

Jan 17 00:50:15 dev-rockysrv.citizix.com systemd[1]: Starting The Apache HTTP Server...
Jan 17 00:50:15 dev-rockysrv.citizix.com systemd[1]: Started The Apache HTTP Server.
Jan 17 00:50:15 dev-rockysrv.citizix.com httpd[41791]: Server configured, listening on: port 80

Active: active (running) indicate that the service is now up and running.

To enable the service on boot, use this command:

1
sudo systemctl enable httpd

Edit PHP and php-fpm Config for Zabbix

Update the php config to optimize for Zabbix installation.

Open the php ini file

1
sudo vim /etc/php.ini

Then modify these settings to the values shown. Update the timezone to fit yours.

1
2
3
4
memory_limit = 2G
max_execution_time = 360
date.timezone = Africa/Nairobi
cgi.fix_pathinfo=0

Next let us edit the php-fpm settings.

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

Then update these values

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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.

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

Add the line shown. Update to your timezonee.

1
php_value[date.timezone] = Africa/Nairobi

Start and enable php-fpm service

The php-fpm service is not started by default. Start using this command:

1
udo systemctl start php-fpm</code>

Confirm by checking the status:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
$ sudo systemctl status php-fpm

&#x25CF; php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2022-01-11 09:22:55 EAT; 31s ago
 Main PID: 43022 (php-fpm)
   Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 6 (limit: 23176)
   Memory: 16.0M
   CGroup: /system.slice/php-fpm.service
           &#x251C;&#x2500;43022 php-fpm: master process (/etc/php-fpm.conf)
           &#x251C;&#x2500;43023 php-fpm: pool www
           &#x251C;&#x2500;43024 php-fpm: pool www
           &#x251C;&#x2500;43025 php-fpm: pool www
           &#x251C;&#x2500;43026 php-fpm: pool www
           &#x2514;&#x2500;43027 php-fpm: pool www

Jan 11 09:22:55 rockysrv.citizix.com systemd&#91;1]: Starting The PHP FastCGI Process Manager...
Jan 11 09:22:55 rockysrv.citizix.com php-fpm&#91;43022]: &#91;11-Jan-2022 09:22:55] WARNING: &#91;pool www] ACL set, listen.owner = 'nginx' is ignored
Jan 11 09:22:55 rockysrv.citizix.com php-fpm&#91;43022]: &#91;11-Jan-2022 09:22:55] WARNING: &#91;pool www] ACL set, listen.group = 'nginx' is ignored
Jan 11 09:22:55 rockysrv.citizix.com systemd&#91;1]: Started The PHP FastCGI Process Manager.

Enable the service to start on boot

1
sudo systemctl enable php-fpm

At this point, we have successfully installed the LAMP stack. We can now install Zabbix

Install Zabbix

Install the zabbix repository

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

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

1
sudo dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-agent

Next, import the database schema:

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

When prompted for a password, provide the Zabbix user’s password.

Edit Zabbix configuration file and update the db credentials

1
sudo vim /etc/zabbix/zabbix_server.conf

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

1
2
3
4
DBHost=localhost
DBName=zabbix
DBUser=zabbix_user
DBPassword=S0mStrongPa$$word

Save the changes and exit the configuration file.

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

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

Additionally, consider enabling them on startup.

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

Configure SELinux & Firewall

If you have firewalld installed and enabled, enable web and Zabbix ports

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

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

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

Complete Zabbix Installation

To complete the installation, launch your browser, and go to this URL: 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.

In the next page you get a 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.

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

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

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

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.

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

Username: 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.

Finally, you will get access to Zabbix’s dashboard

That is it! We have successfully installed the Zabbix monitoring tool on Rocky Linux 8.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy