How to install and configure Zabbix 6- on Rocky Linux 8

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:

# dnf install @httpd

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

# systemctl start httpd
# systemctl enable httpd

To verify that Apache is running, execute the command:

# systemctl status httpd

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:

# vi /etc/yum.repos.d/mariadb.repo
[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:

# rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

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

# 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.

# systemctl start mariadb
# systemctl enable mariadb

Confirm that the database server is running:

# systemctl status mariadb

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

# mysql -V

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.

#  mysql_secure_installation

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


 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.


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:

#  mysql -u root -p

Then set the root password as follows.

 > set password = password("redhat");

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

 > ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("redhat");

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:

#  dnf module list php

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

# dnf module reset php
# dnf module install php: 8.0

Next, install the required PHP modules for Zabbix installation.

# dnf install php php-curl php-fpm php-mysqlnd

To check the version of PHP, run.

# php -v

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.

# systemctl start php-fpm
# systemctl enable php-fpm

Then verify its status.

# systemctl status php-fpm

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.

rpm -Uvh https://repo.zabbix.com/zabbix/6.5/rocky/8/x86_64/zabbix-release-6.5-2.el8.noarch.rpm 

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

dnf install --nogpgcheck 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.

# mysql -u root -p

> create database zabbix_db character set utf8 collate utf8_bin;

> CREATE USER zabbix_user@localhost IDENTIFIED BY 'redhat';

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

> GRANT ALL PRIVILEGES ON zabbix_db.* TO zabbix_user@localhost;

Then effect the changes and exit the database server

> FLUSH PRIVILEGES;

> EXIT;

Next, import the database schema:

# cp /usr/share/zabbix-sql-scripts/mysql/server.sql.gz /root/
# zcat /usr/share/zabbix-sql-scripts/mysql/server.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

# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix_db
DBUser=zabbix_user
DBPassword=redhat

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.

# vi  /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.

# vi /etc/php-fpm.d/zabbix.conf

Add the line shown.

php_value[date.timezone] = Asia/Kolkata

Save and exit.

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

# systemctl restart zabbix-server zabbix-agent httpd php-fpm

Additionally, consider enabling them on startup.

# systemctl enable zabbix-server zabbix-agent httpd php-fpm

Step 4: Complete Zabbix Installation in Rocky/Alma Linux

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

http://zap01.darole.org/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 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:

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.


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

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











Monitor VMware with Zabbix

Configure Zabbix server

1. Open the Zabbix server configuration file.

# vi /etc/zabbix/zabbix_server.conf

2. Locate and set the StartVMwareCollectors parameter in Zabbix server configuration file to 2 or more (the default value is 0).

### Option: StartVMwareCollectors
#       Number of pre-forked vmware collector instances.
#
# Mandatory: no
# Range: 0-250
# Default:
# StartVMwareCollectors=0
StartVMwareCollectors=2

3. Restart Zabbix server.

# systemctl restart zabbix-server

1. Log into Zabbix frontend.

2. Create a host in Zabbix web interface:

  • In the Host name field, enter a host name (for example, "VMware environment").
  • In the Templates field, type or select the "VMware FQDN" (or "VMware") template. For more information on these templates, see Virtual machine monitoring.
  • In the Host groups field, type or select a host group (for example, a new host group "VMware").


In the Macros tab, set the following host macros:

  • {$VMWARE.URL} - VMware service (vCenter or ESXi hypervisor) SDK URL (https://servername/sdk)
  • {$VMWARE.USERNAME} - VMware service user name
  • {$VMWARE.PASSWORD} - VMware service {$VMWARE.USERNAME} user password


3. Click the Add button to create the host. This host will represent your VMware environment.



No comments:

Post a Comment