11.12.2024

How to Install and Configure Zabbix on CentOS 8

In this tutorial, we will set up the Zabbix 5 server monitoring system on CentOS 8. The database management system will be Postgresql-12 and the Nginx web server.

Installing the necessary packages for Zabbix

Let's install the Zabbix repository and clear the package manager cache.

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
dnf clean all

After adding the repository, we can now install the necessary packages.

dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-nginx-conf zabbix-agent

Postgresql-12 installation

Install the Postgresql-12 repository and clear the cache.

rpm -Uvh https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf clean all

Disable the pre-installed DBMS module.

dnf -qy module disable postgresql

After that set up the Postgresql-12 packages.

dnf -y install postgresql12 postgresql12-server

Now let’s initialize the database.

/usr/pgsql-12/bin/postgresql-12-setup initdb

Now we can activate the service and make it start at system startup.

systemctl enable --now postgresql-12

Database configuration

Create a new Postgresql user for Zabbix. Enter the password for it when prompted.

sudo -u postgres createuser --pwprompt zabbix

Then create a new database to work with the server monitoring system.

sudo -u postgres createdb -O zabbix zabbix

Let’s import the starting schema and information into the database for Zabbix. When prompted, type the password for the zabbix user that we recently created.

zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix

In the /etc/zabbix/zabbix_server.conf file uncomment the DBPassword line and enter the password for accessing the database here.

DBPassword=zabbix

To be able to establish connection from Zabbix with the database, open the /var/lib/pgsql/12/data/pg_hba.conf file and find the lines:

# IPv4 local connections:
host all all 127.0.0.1/32 ident

Change the method to password.

host all all 127.0.0.1/32 password

And restart the DBMS.

systemctl restart postgresql-12

Nginx configuration

Open the /etc/nginx/conf.d/zabbix.conf file and uncomment the listen and server_name parameters. In the last one enter the domain mane of your server or _ if you only want to access it using an IP address.

server {
listen 80;
server_name _;
...

In the last case, you also need to comment out the entire server section in the /etc/nginx/nginx.conf file.

# server {
# listen 80 default_server;
# listen [::]:80 default_server;
# server_name _;
# root /usr/share/nginx/html;
...

In the /etc/php-fpm.d/zabbix.conf file uncomment the php_value[date.timezone] parameter and set your timezone.

php_value[date.timezone] = Europe/Prague

Now restart the configured applications and make them to launch with the system boot.

systemctl restart zabbix-server zabbix-agent nginx php-fpm
systemctl enable zabbix-server zabbix-agent nginx php-fpm

Zabbix frontend configuring

Open the IP address of your server in the browser.

Screenshot 1. Zabbix welcome page.

Check if all the prerequisites are OK on the second step.
In the third step, enter 127.0.0.1 in the Database Host field and the password for the database in the corresponding field.

Screenshot 2. Database settings.

Now follow to the end of configuration and leave the default parameters.
Login Admin and password zabbix are used to log in to the administration panel.

Screenshot 3. Zabbix login page