How to Install Zabbix 4 on Centos RHEL

How to Install Zabbix 5.0 or 5.4 on CentOS 8 [Step-by-Step]

Zabbix server is installable on any Linux distribution, but in this tutorial, I will show you how to install the latest Zabbix 5.0 LTS or 5.4 Standard release on CentOS 8 / RHEL 8 / Oracle Linux 8.

Zabbix is 100% free open-source ultimate enterprise-level software designed for monitoring availability and performance of IT infrastructure components and services. You can read a case-study about Zabbix popularity and find out more about open-source movement in this article.

Zabbix 5 Dashboard
Zabbix 5 dashboard

Enough of talk lets do some work! First, we will install and configure Zabbix server, then a database and lastly the frontend – check the picture bellow for a better understanding of Zabbix architecture.

Picture showing Zabbix architecture
Picture showing Zabbix architecture

This guide is for installing Zabbix monitoring system (Server) on CentOS / RHEL / Oracle Linux, while guide for installing Zabbix-Proxy can be found on this link.

Step 1: Set SELinux to permissive mode

Configure SELinux to work in permissive mode:

setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

This way, SELinux will not block anything, but the audit log will fill up with what would have been denied. And later in step 12, we can create an SELinux policy based on that.

Step 2: Install Zabbix server, frontend, and agent

Setup Zabbix 5 RPM package on CentOS 8, clean repo and install Zabbix server, frontend, and agent. Choose 5.0 LTS release (stable, 5-year support) or 5.4 standard release (more features, 6-month support, more bugs).

Zabbix 5.0 LTS version (supported until May, 2025)
rpm -Uvh
dnf clean all
dnf -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent


Zabbix 5.4 standard version (supported until November, 2021)
rpm -Uvh
dnf clean all
dnf -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-agent

You can find more information about Zabbix’s life cycle and release policies on the official website.

Step 3: Install and configure database

In this installation, I will use password rootDBpass as root password and zabbixDBpass as Zabbix password for DB. Consider changing your password for security reasons.

a. Install MariaDB

dnf -y install mariadb-server && systemctl start mariadb && systemctl enable mariadb

b. Reset root password for database

Secure MySQL by changing the default password for MySQL root:

Enter current password for root (enter for none): Press the Enter
Set root password? [Y/n]: Y
New password: <Enter root DB password>
Re-enter new password: <Repeat root DB password>
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

c. Create database

Create a database for Zabbix directly from the terminal using these two commands:

mysql -uroot -p'rootDBpass' -e "create database zabbix character set utf8 collate utf8_bin;"
mysql -uroot -p'rootDBpass' -e "grant all privileges on zabbix.* to [email protected] identified by 'zabbixDBpass';"

d. Import initial schema and data

Temporary disable strict mode (ZBX-16465) to avoid MySQL error “ERROR 1118 (42000) at line 1284: Row size too large (> 8126)” :

mysql -uroot -p'rootDBpass' zabbix -e "set global innodb_strict_mode='OFF';"

Import database shema for Zabbix server (could last up to 10 minutes):

Zabbix 5.0 LTS version
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p'zabbixDBpass' zabbix


Zabbix 5.4 standard version
zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbix -p'zabbixDBpass' zabbix

Enable strict mode:

mysql -uroot -p'rootDBpass' zabbix -e "set global innodb_strict_mode='ON';"

e. Enter database password in Zabbix configuration file

Open zabbix_server.conf file with command: “nano /etc/zabbix/zabbix_server.conf” and add database password in this format anywhere in file:


Save and exit file (ctrl+x, followed by y and enter).

Step 4: Start Zabbix server and agent processes

systemctl restart zabbix-server zabbix-agent
systemctl enable zabbix-server zabbix-agent

Step 5: Configure firewall

firewall-cmd --add-service={http,https} --permanent
firewall-cmd --add-port={10051/tcp,10050/tcp} --permanent
firewall-cmd --reload

Step 6: Configure Zabbix frontend

a. Configure PHP for Zabbix frontend

Edit file “/etc/php-fpm.d/zabbix.conf” with command:

nano /etc/php-fpm.d/zabbix.conf

Uncomment line in zabbix.conf that starts with “; php_value date.timezone Europe/Riga” by removing symbol “;” and set the right timezone for your country, for example:

php_value date.timezone Europe/Amsterdam

Save and exit file (ctrl+x, followed by y and enter)

b. Restart Apache web server and make it start at system boot

systemctl restart httpd php-fpm
systemctl enable httpd php-fpm

c. Configure web frontend

Connect to your newly installed Zabbix frontend using URL “http://server_ip_or_dns_name/zabbix” to initiate the Zabbix installation wizard.

In my case, that URL would be “” because I have installed Zabbix on the server with IP address (you can find the IP address of your server by typing “ip a” command in the terminal).

Basically, in this wizard you only need to enter a password for Zabbix DB user and for everything else just click “Next step“. In this guide, I have used a zabbixDBpass as a database password, but if you set something else, be sure to enter the correct password when prompted by the wizard.

1. Installation step: Welcome screen
1. Installation step: Welcome screen
2. Installation step: Pre-requisites check
2. Installation step: Pre-requisites check
3. Installation step: Configure DB connection
3. Installation step: Configure DB connection
4. Installation step: Configure Zabbix server
4. Installation step: Configure Zabbix server
5. Installation step: Pre-installation summary
5. Installation step: Pre-installation summary
6. Installation step: Finish
6. Installation step: Finish

That’s it, you have installed Zabbix monitoring system!

Step 7: Login to frontend using Zabbix default login credentials

Use Zabbix default admin username “Admin” and password “zabbix” (without quotes) to login to Zabbix frontend at URL “http://server_ip_or_dns_name/zabbix” via your browser.


In my example, I have installed Zabbix on server so I will enter in my browsers URL field (you can find the IP address of your server by typing “ip a” command in the terminal)

zabbix 5.0 dashboard
Zabbix 5.0 Dashboard

You have successfully installed Zabbix 5 on CentOS 8 and now you can monitor anything!
No need to change anything else as other steps are optional.

How to create MySQL partitions on History and Events tables
Optimizing Zabbix server and MySQL database
Managing Zabbix / MySQL / Apache service
Enable and configure SELinux on Zabbix

Step 8: Create MySQL partitions on History and Events tables

Zabbix’s housekeeping process is responsible for deleting old trend and history data. Removing old data from the database using SQL delete query can negatively impact database performance. Many of us have received that annoying alarm “Zabbix housekeeper processes more than 75% busy” because of that.

That problem can be easily solved with the database partitioning. Partitioning creates tables for each hour or day and drops them when they are not needed anymore. SQL DROP is way more efficient than the DELETE statement.

You can partition MySQL tables in 5 minutes using this simple guide.

Step 9: Optimizing Zabbix Server (optional)

Don’t bother with this optimization if you are monitoring a small number of devices, but if you are planning to monitor a large number of devices then continue with this step.

Open “zabbix_server.conf” file with command: “nano /etc/zabbix/zabbix_server.conf” and add this configuration anywhere in file:


Save and exit file (ctrl+x, followed by y and enter).

This is not a perfect configuration, keep in mind that you can optimize it even more. Let’s say if you don’t use ICMP checks then set the “StartPingers” parameter to 1 or if you don’t use active agents then set “StartTrappers” to 1 and so on. You can find out more about the parameters supported in a Zabbix server configuration file in the official documentation.

If you try to start the Zabbix server you will receive an error “[Z3001] connection to database 'Zabbix' failed: [1040] Too many connections” in the log “/var/log/zabbix/zabbix_server.log” because we are using more Zabbix server processes than MySQL can handle. We need to increase the maximum permitted number of simultaneous client connections and optimize MySQL – so move to the next step.

Step 10: Optimizing MySQL/MariaDB database (optional)

a. Create custom MySQL configuration file

Create file “10_my_tweaks.cnf" with “nano /etc/my.cnf.d/10_my_tweaks.cnf” and paste this configuration:

max_connections = 404
innodb_buffer_pool_size = 800M

innodb-log-file-size = 128M
innodb-log-buffer-size = 128M
innodb-file-per-table = 1
innodb_buffer_pool_instances = 8
innodb_old_blocks_time = 1000
innodb_stats_on_metadata = off
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-flush-log-at-trx-commit = 2

tmp-table-size = 96M
max-heap-table-size = 96M
open_files_limit = 65535
max_connect_errors = 1000000
connect_timeout = 60
wait_timeout = 28800

Save and exit the file (ctrl+x, followed by y and enter) and set the correct file permission:

chown mysql:mysql /etc/my.cnf.d/10_my_tweaks.cnf
chmod 644 /etc/my.cnf.d/10_my_tweaks.cnf

Two things to remember!

Configuration parameter max_connections must be larger than the total number of all Zabbix proxy processes plus 150. You can use the command below to automatically check the number of Zabbix processes and add 150 to that number:

egrep "^Start.+=[0-9]" /etc/zabbix/zabbix_server.conf | awk -F "=" '{s+=$2} END {print s+150}'

The second most important parameter is innodb_buffer_pool_size, which determines how much memory can MySQL get for caching InnoDB tables and index data. You should set that parameter to 70% of system memory if only database is installed on server.

However, in this case, we are sharing a server with Zabbix and Apache processes so you should set innodb_buffer_pool_size to 40% of total system memory. That would be 800 MB because my CentOS server has 2 GB RAM.

I didn’t have any problems with memory, but if your Zabbix proxy crashes because of lack of memory, reduce “innodb_buffer_pool_size” and restart MySQL server.

Note that if you follow this configuration, you will receive “Too many processes on the Zabbix server” alarm in Zabbix frontend due to the new Zabbix configuration. It is safe to increase the trigger threshold or turn off that alarm (select “Problems” tab → left click on the alarm → select “Configuration” → remove the check from “Enabled” → hit the “Update” button)

b. Restart Zabbix Server and MySQL service

Stop and start the services in the same order as below:

systemctl stop zabbix-server
systemctl stop mysql
systemctl start mysql
systemctl start zabbix-server

Step 11: How to manage Zabbix / MySQL / Apache service

Sometimes you will need to check or restart Zabbix, MySQL or Apache service – use commands below to do that.

Zabbix Server
systemctl <status/restart/start/stop> zabbix-server

MySQL/MariaDB Server
systemctl <status/restart/start/stop> mysql

Apache Server
systemctl <status/restart/start/stop> httpd

PHP FastCGI Process Manager
systemctl <status/restart/start/stop> php-fpm

Zabbix Agent
systemctl <status/restart/start/stop> zabbix-agent

Step 12: Enable and configure SELinux on Zabbix

While it is acceptable to disable SELinux in a lab environment, depending on the requirements of the local security IT team, you may need to enable and configure SELinux in your production environment.

At the beginning of this guide, we did not turn off SELinux completely but configure it to work in the permissive mode which means it will log all the security errors but will not block anything.

If you accidentally left it in enforcing mode then you will receive the “Zabbix server is not running: the information displayed may not be current” warning on the Zabbix frontend and “cannot set resource limit: [13] Permission denied” in the log file.

Don’t worry, this can be easily fixed, so without further delay, let’s configure SELinux for Zabbix!

a) SELinux: Allow http daemon to connect to Zabbix:

Enable SELinux  boolean “httpd_can_connect_zabbix” that will allow http daemon to connect to Zabbix:

setsebool -P httpd_can_connect_zabbix 1

b) SELinux: Allow Zabbix to connect to all TCP ports:

Enable SELinux  boolean “zabbix_can_network” that will allow Zabbix to connect to all TCP ports :

setsebool -P zabbix_can_network 1

c) Set SELinux to work in enforcing mode

Turn on SELinux by setting it to work in enforcing mode:

setenforce 1 && sed -i 's/^SELINUX=.*/SELINUX=enforcing/g' /etc/selinux/config

And check SELinux status :

# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual (secure)
Max kernel policy version: 31

d) Create additional SELINUX policy for Zabbix

Just in case, we will create an additional SELinux policy for each error in the audit log (“/var/log/audit/audit.log“)

To do this, we will need the policycoreutils-python tool, so let’s install it:

dnf -y install policycoreutils-python-utils

Create a custom policy package:

grep "denied.*zabbix" /var/log/audit/audit.log | audit2allow -M zabbix_policy

Install custom SELinux policy package:

semodule -i zabbix_policy.pp

Well done! You have configured SELinux for Zabbix!

Step 13: Upgrade between minor Zabbix versions

I wrote about upgrade procedures in my post about Zabbix upgrade. Zabbix’s team releases new minor versions at least once a month. The main purpose of minor upgrades is to fix bugs (hotfix) and sometimes even bring new functionality. Therefore, try to do a minor upgrade of Zabbix at least once a month.

There is no need for backups when doing a minor upgrade, they are completely safe. With this command you can easily upgrade minor versions of 5.0.x (for example, from 5.0.1 to 5.0.5):

dnf upgrade 'zabbix-*'

And restart Zabbix server afterward:

systemctl restart zabbix-server

Thank you for reading.