Zabbix is a powerful open-source monitoring solution for IT infrastructure—networks, servers, virtual machines, and cloud services. It collects metrics such as network utilization, CPU load, and disk usage, and gives administrators flexibility to monitor exactly what matters. The backend is written in C; the web frontend uses PHP. Zabbix can send alerts when metrics cross thresholds you define, and it supports both agent-based and agentless monitoring. Installing Zabbix agents on hosts gives you detailed metrics (CPU, network, disk) for more accurate monitoring.
This guide walks you through installing and configuring Zabbix Server 6 (6.2) on Rocky Linux 9 and Alma Linux 9, using MariaDB, PHP 8.2, and Apache. The same steps apply to other RHEL 9–based systems such as Oracle Linux 9.
Prerequisites
- A fresh Rocky Linux 9 or Alma Linux 9 server (or equivalent RHEL 9 clone) with root or sudo access
- At least 2 GB RAM and 2 CPU cores recommended for a small deployment
- Network access to install packages and to reach the Zabbix web interface from your browser
Related Articles
- How to Install and Configure Zabbix Server 6 on Ubuntu 22.04
- How to Install and Configure Zabbix Server 5 on Rocky Linux/Alma Linux 8
- How to Install and Configure Zabbix Server 6 on Ubuntu 20.04
- How to Install Zabbix Agent on Rocky Linux/Alma Linux 8
- How to Install and Configure Zabbix Agent on Ubuntu 20.04
- How to Add Host in Zabbix Server to Monitor
- How to Install and Configure Zabbix Agent on OpenSUSE Leap 15.3
Update System Packages
Update the system and install any useful utilities:
sudo dnf -y update
sudo dnf install -y vim
Install MariaDB
Zabbix requires a MySQL-compatible database. We use MariaDB, an open-source drop-in replacement for MySQL, available in the default repositories as mariadb-server.
Install it with this command:
sudo dnf install -y mariadb-server
Verify the installed package:
$ rpm -qi mariadb-server
Name : mariadb-server
Epoch : 3
Version : 10.5.16
Release : 2.el9_0
Architecture: x86_64
...
Summary : The MariaDB server and related files
The Service will not be started by default. Start with this command:
sudo systemctl start mariadb
Confirm the status with this command:
$ sudo systemctl status mariadb
â—Ź mariadb.service - MariaDB 10.5 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2022-11-23 07:20:31 UTC; 4s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 206224 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited, status=0/SUCCESS)
Process: 206246 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
Process: 206343 ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exited, status=0/SUCCESS)
Main PID: 206328 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 14 (limit: 22990)
Memory: 74.8M
CPU: 585ms
CGroup: /system.slice/mariadb.service
└─206328 /usr/libexec/mariadbd --basedir=/usr
Nov 23 07:20:31 fiddle-one mariadb-prepare-db-dir[206285]: you need to be the system 'mysql' user to connect.
Nov 23 07:20:31 fiddle-one mariadb-prepare-db-dir[206285]: After connecting you can set the password, if you would need to be
Nov 23 07:20:31 fiddle-one mariadb-prepare-db-dir[206285]: able to connect as any of these users with a password and without sudo
Nov 23 07:20:31 fiddle-one mariadb-prepare-db-dir[206285]: See the MariaDB Knowledgebase at https://mariadb.com/kb
Nov 23 07:20:31 fiddle-one mariadb-prepare-db-dir[206285]: Please report any problems at https://mariadb.org/jira
Nov 23 07:20:31 fiddle-one mariadb-prepare-db-dir[206285]: The latest information about MariaDB is available at https://mariadb.org/.
Nov 23 07:20:31 fiddle-one mariadb-prepare-db-dir[206285]: Consider joining MariaDB's strong and vibrant community:
Nov 23 07:20:31 fiddle-one mariadb-prepare-db-dir[206285]: https://mariadb.org/get-involved/
Nov 23 07:20:31 fiddle-one mariadbd[206328]: 2022-11-23 7:20:31 0 [Note] /usr/libexec/mariadbd (mysqld 10.5.16-MariaDB) starting as process 206>
Nov 23 07:20:31 fiddle-one systemd: Started MariaDB 10.5 database server.
To ensure that mariadb starts on boot, enable it with this systemd command:
sudo systemctl enable mariadb
Once MariaDB is running, secure it using the provided script:
sudo mysql_secure_installation
The script will prompt you to set a root password, remove anonymous users, disallow root login remotely, and remove the test database. Accept the recommended options for a production setup.
To confirm the version of MariaDB installed, run the command:
$ mysql -V
mysql Ver 15.1 Distrib 10.5.16-MariaDB, for Linux (x86_64) using EditLine wrapper
For more on MariaDB installation and configuration, see How to Install and Configure MariaDB 10 in Rocky Linux/Alma Linux 8.
Create Database and User for Zabbix
Create a dedicated database and user for Zabbix (see MySQL permissions guide for more on managing users). Connect to the server:
mysql -u root -p
After supplying the root password, run the following at the MySQL prompt (replace the password with a strong one):
CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'zabbix_user'@'localhost' IDENTIFIED BY 'YourStrongPasswordHere';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Use a strong password and note the database name, username, and password for the Zabbix server configuration later. Using 'zabbix_user'@'localhost' instead of '%' is more secure when the database is on the same host as Zabbix.
Install PHP and Required Modules
The default PHP in Rocky Linux 9 may be older than Zabbix 6 requires. Install the Remi repository to get PHP 8.2:
sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-9.rpm
Enable version 8.2 of php
sudo dnf module enable -y php:remi-8.2
Confirm the module is enabled with sudo dnf module list php, then install PHP and the extensions required by Zabbix:
sudo dnf install -y php \
php-cli \
php-common \
php-fpm \
php-curl \
php-mysqlnd
Check php version
$ php -v
PHP 8.2.0RC6 (cli) (built: Nov 8 2022 06:25:57) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.0RC6, Copyright (c) Zend Technologies
with Zend OPcache v8.2.0RC6, Copyright (c), by Zend Technologies
For more on the LAMP stack, see How to Install Apache and PHP (LAMP stack) on Rocky Linux/CentOS 8.
Install Apache Web Server
Install and start the Apache httpd service:
sudo dnf install -y httpd
sudo systemctl start httpd
Enable httpd to start at boot, then verify it is running:
sudo systemctl enable httpd
sudo systemctl status httpd # expect Active: active (running)
Configure PHP and PHP-FPM for Zabbix
Tune PHP for Zabbix by editing the main PHP configuration:
sudo vim /etc/php.ini
Set or adjust the following (use your own timezone):
memory_limit = 2G
max_execution_time = 360
date.timezone = Africa/Nairobi
cgi.fix_pathinfo=0
Edit the PHP-FPM pool configuration:
sudo vim /etc/php-fpm.d/www.conf
Ensure these values are set:
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 and exit. Then start and enable PHP-FPM:
Start and Enable PHP-FPM
The php-fpm service is not started by default. Start using this command:
sudo systemctl start php-fpm
Confirm by checking the status:
$ sudo systemctl status php-fpm
â—Ź 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 Wed 2022-11-23 07:49:52 UTC; 2min 56s ago
Main PID: 207480 (php-fpm)
Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 6 (limit: 22990)
Memory: 12.6M
CPU: 94ms
CGroup: /system.slice/php-fpm.service
├─207480 "php-fpm: master process (/etc/php-fpm.conf)"
├─207481 "php-fpm: pool www"
├─207482 "php-fpm: pool www"
├─207483 "php-fpm: pool www"
├─207484 "php-fpm: pool www"
└─207485 "php-fpm: pool www"
Nov 23 07:49:52 fiddle-one systemd[1]: Starting The PHP FastCGI Process Manager...
Nov 23 07:49:52 fiddle-one systemd[1]: Started The PHP FastCGI Process Manager.
Enable the service to start on boot
sudo systemctl enable php-fpm
At this point, we have successfully installed the LAMP stack. We can now install Zabbix
Install Zabbix
If you use EPEL, disable its Zabbix packages so the official Zabbix repo is used. Edit /etc/yum.repos.d/epel.repo and under the [epel] section add:
[epel]
...
excludepkgs=zabbix*
Install the zabbix repository
sudo rpm -Uvh https://repo.zabbix.com/zabbix/6.2/rhel/9/x86_64/zabbix-release-6.2-3.el9.noarch.rpm
sudo dnf clean all
Once the repository is installed, install the Zabbix server, Zabbix agent, and the associated Zabbix packages.
sudo dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
Import the Zabbix database schema (use the password you set for zabbix_user):
sudo zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -u zabbix_user -p zabbix
When prompted for a password, provide the Zabbix user’s password.
Edit Zabbix configuration file and update the db credentials
sudo vim /etc/zabbix/zabbix_server.conf
Set DBHost, DBName, DBUser, and DBPassword to match the database and user you created:
DBHost=localhost
DBName=zabbix
DBUser=zabbix_user
DBPassword=YourStrongPasswordHere
Save and exit. Optionally set the PHP timezone for the Zabbix frontend (the file is created when you install the Zabbix packages):
echo 'php_value[date.timezone] = Africa/Nairobi' | sudo tee -a /etc/php-fpm.d/zabbix.conf
Use your own timezone (e.g. America/New_York, Europe/London). If the file does not exist yet, create it and add the line, or skip and set the timezone in the web wizard. Then restart all services:
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
Configure SELinux & Firewall
If you have firewalld installed and enabled, enable web and Zabbix ports
sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --add-port={10050,10051}/tcp --permanent
sudo firewall-cmd --reload
For the Zabbix web interface to work under the default Apache and PHP-FPM setup, SELinux may block access. You can set SELinux to permissive temporarily (requires reboot for permanent change):
# Temporary (until reboot)
sudo setenforce 0
# Permanent (after reboot)
sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
For production, consider keeping SELinux enforcing and configuring the correct contexts for Zabbix (e.g. with semanage and restorecon) instead of disabling it.
Complete Zabbix Installation via Web Wizard
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, enter your database name, user, and password. Leave the database port at 0 (default). Click 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.
You will be taken to the Zabbix login page. Use the default credentials:
- Username:
Admin - Password:
zabbix
Click Sign in to open the dashboard. Change the default password immediately from Administration → Users → Admin for security.
Summary
You have installed Zabbix Server 6 on Rocky Linux 9 or Alma Linux 9 with:
- MariaDB as the database
- PHP 8.2 and PHP-FPM
- Apache (httpd) serving the Zabbix web frontend
- Firewall rules for HTTP and Zabbix (80, 10050, 10051)
- Optional SELinux adjustment for the web UI
Troubleshooting
- 502 Bad Gateway or blank page at /zabbix: Ensure PHP-FPM is running (
sudo systemctl status php-fpm) and that Apache can talk to the PHP-FPM socket. Restarthttpdandphp-fpmafter config changes. - Database connection errors in the wizard: Check that MariaDB is running, the
zabbixdatabase exists, and the credentials in/etc/zabbix/zabbix_server.confmatch the user you created. Test withmysql -u zabbix_user -p zabbix -e 'SELECT 1'. - Cannot access /zabbix from browser: Open firewall ports 80, 10050, and 10051; if SELinux is enforcing, use
setenforce 0temporarily or set the proper Zabbix SELinux context.
Next Steps
- Add hosts to Zabbix and install Zabbix agents on servers you want to monitor
- Create triggers, dashboards, and alerting (email, Slack, etc.) from the Zabbix UI
- Harden the server: use HTTPS (e.g. with Nginx or Apache TLS), restrict database access, and keep Zabbix and the OS updated