Install Zabbix 6.4 on AlmaLinux 9: Comprehensive Guide
This tutorial provides a step-by-step guide to Install Zabbix 6.4 on AlmaLinux 9. You will also learn how to access your Zabbix dashboard through a web interface. Zabbix is a powerful open-source monitoring solution that provides critical metrics for your infrastructure, including network utilization, CPU load, and disk space consumption. Understanding how to Install Zabbix 6.4 on AlmaLinux 9 is crucial for system administrators and DevOps engineers.
Zabbix 6.4 represents the latest iteration of Zabbix, boasting enhanced features, performance improvements, and bug fixes. For a comprehensive understanding of the changes, refer to the official Zabbix 6.4 Release Notes. Follow the detailed instructions below to Install Zabbix 6.4 on AlmaLinux 9.
Full Steps To Install and Configure Zabbix 6.4 on AlmaLinux 9
Before you begin the process to Install Zabbix 6.4 on AlmaLinux 9, ensure you have the necessary prerequisites in place.
Requirements for Zabbix 6.4 Setup
-
Server Setup: You should be logged in to your AlmaLinux 9 server as a non-root user with sudo privileges. A basic firewall configuration is also required. You can refer to our guide on Initial Server Setup with AlmaLinux 9 for detailed instructions.
-
LAMP Stack: A fully functional LAMP (Linux, Apache, MariaDB/MySQL, PHP) stack needs to be installed on your server. Follow our guide on Install LAMP Stack on AlmaLinux 9 to complete this step.
Once these prerequisites are met, proceed with the following steps to Install Zabbix 6.4 on AlmaLinux 9.
Step 1 – Download and Install Zabbix 6.4 on AlmaLinux 9
First, if you have an EPEL repository installed, disable the Zabbix packages provided by EPEL to avoid conflicts. Open the EPEL repository configuration file:
sudo vi /etc/yum.repos.d/epel.repo
Add the following line within the [epel]
section:
[epel]
...
excludepkgs=zabbix*
Save and close the file.
Next, add the official Zabbix 6.4 repository to your AlmaLinux 9 system:
# sudo rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
# sudo dnf clean all
Now, install the Zabbix server, web frontend, database support, SQL scripts, SELinux policy, and agent using the following command:
sudo dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent -y
After the installation is complete, you need to create a Zabbix database and user in MariaDB.
Step 2 – Configure MariaDB for Zabbix on AlmaLinux 9
Log in to the MariaDB console as the root user:
sudo mysql -u root -p
Within the MariaDB console, create a dedicated user for Zabbix. Replace <mark>zabbixuser</mark>
with your desired username and <mark>password</mark>
with a strong password:
MariaDB [(none)]> CREATE USER <mark>zabbixuser</mark>@localhost IDENTIFIED BY '<mark>password</mark>';
Create the Zabbix database:
MariaDB [(none)]> CREATE DATABASE <mark>zabbixdb</mark> character set utf8mb4 collate utf8mb4_bin;
Grant the necessary privileges to the Zabbix user on the Zabbix database:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON <mark>zabbixdb</mark>.* TO <mark>zabbixuser</mark>@localhost;
Flush the privileges to apply the changes and exit the MariaDB console:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Import Database Schema
Import the Zabbix database schema using the following command. You will be prompted for the Zabbix user’s password:
# sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -u <mark>zabbixuser</mark> -p <mark>zabbixdb</mark>
Change Database Settings on Zabbix Configuration File
Edit the Zabbix server configuration file:
sudo vi /etc/zabbix/zabbix_server.conf
Locate the following lines and update them with your database details. Replace <mark>zabbixdb</mark>
, <mark>zabbixuser</mark>
, and <mark>password</mark>
with the actual values you used:
DBHost=localhost
DBName=<mark>zabbixdb</mark>
DBUser=<mark>zabbixuser</mark>
DBPassword=<mark>password</mark>
Uncomment the DBHost
and DBPassword
lines by removing the #
character at the beginning of the line.
Save and close the file.
Step 3 – Configure PHP-FPM for Zabbix on AlmaLinux 9
Specify the correct timezone in the PHP-FPM configuration for Zabbix. Edit the Zabbix PHP-FPM configuration file:
sudo vi /etc/php-fpm.d/zabbix.conf
Add the following line, replacing America/New_York
with your appropriate timezone:
php_value[date.timezone] = America/New_York
Save and close the file.
Restart the Zabbix server, agent, Apache, and PHP-FPM services to apply the changes:
sudo systemctl restart zabbix-server zabbix-agent httpd php-fpm
Enable the services to start automatically on system boot:
sudo systemctl enable zabbix-server zabbix-agent php-fpm
Step 4 – Configure SELinux and Firewall for Zabbix on AlmaLinux 9
Temporarily disable SELinux and set it to permissive mode for persistent configuration.
# sudo setenforce 0
# sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
Allow traffic on ports 10050
and 10051
through the AlmaLinux firewall:
# sudo firewall-cmd --add-service=http --permanent
# sudo firewall-cmd --add-port={10051,10050}/tcp --permanent
Reload the firewall to apply the changes:
sudo firewall-cmd --reload
Step 5 – Access Zabbix 6.4 Dashboard via Web Interface
Open your web browser and navigate to the following URL, replacing <mark>server-ip</mark>
with your server’s IP address:
http://<mark>server-ip</mark>/zabbix
Follow the on-screen instructions to complete the Zabbix frontend setup. This involves checking prerequisites, configuring the database connection, setting the server name and default theme, reviewing the pre-installation summary, and finishing the installation.
Finally, log in to the Zabbix dashboard using the default credentials:
- Username:
<mark>Admin</mark>
- Password:
<mark>zabbix</mark>
You should now see the Zabbix 6.4 dashboard.
From your dashboard, you can monitor various aspects of your infrastructure.
Conclusion
You have successfully completed the process to Install Zabbix 6.4 on AlmaLinux 9. Zabbix is a powerful monitoring tool that you can use for your servers and systems.
Alternative Solutions for Installing Zabbix
While the above guide provides a comprehensive method to install Zabbix 6.4 on AlmaLinux 9, alternative approaches exist, offering different levels of automation and flexibility.
1. Using Docker Compose
Docker Compose allows you to define and manage multi-container Docker applications. Using Docker Compose to deploy Zabbix offers several advantages, including simplified setup, portability, and isolation.
Explanation:
Instead of manually installing and configuring each Zabbix component (server, database, frontend), you can define all the required services in a docker-compose.yml
file. This file specifies the Docker images to use, their dependencies, network configurations, and environment variables. Docker Compose then automatically pulls the images, creates the containers, and links them together according to your configuration.
Example docker-compose.yml
:
version: "3.8"
services:
zabbix-server:
image: zabbix/zabbix-server-mysql:latest
ports:
- "10051:10051"
volumes:
- zabbix_server_data:/var/lib/zabbix
environment:
- DB_SERVER_HOST=zabbix-db
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=zabbix
depends_on:
- zabbix-db
zabbix-db:
image: mysql:8.0
ports:
- "3306:3306"
volumes:
- zabbix_db_data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root_password
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=zabbix
zabbix-web-apache:
image: zabbix/zabbix-web-apache-mysql:latest
ports:
- "8080:80"
- "443:443"
environment:
- PHP_TZ=America/New_York
- ZBX_SERVER_HOST=zabbix-server
depends_on:
- zabbix-server
volumes:
zabbix_server_data:
zabbix_db_data:
Steps:
- Install Docker and Docker Compose on your AlmaLinux 9 server.
- Create a
docker-compose.yml
file with the above content. - Customize the environment variables (e.g., passwords, time zone) to suit your needs.
- Run
docker-compose up -d
to start the Zabbix containers in detached mode. - Access the Zabbix frontend through your browser at
http://<server-ip>:8080
.
2. Using Ansible Automation
Ansible is a powerful automation tool that allows you to define infrastructure as code. You can use Ansible to automate the entire process of installing and configuring Zabbix 6.4 on AlmaLinux 9.
Explanation:
With Ansible, you create "playbooks" that describe the desired state of your system. These playbooks consist of a series of tasks that Ansible executes on the target server. This ensures a consistent and repeatable installation process.
Example Ansible Playbook Snippet (install_zabbix.yml):
---
- hosts: zabbix_server
become: true
tasks:
- name: Add Zabbix repository
yum_repository:
name: zabbix
description: Zabbix Official Repository
baseurl: https://repo.zabbix.com/zabbix/6.4/rhel/9/$basearch/
gpgcheck: true
gpgkey: https://repo.zabbix.com/zabbix/6.4/RPM-GPG-KEY-ZABBIX
- name: Install Zabbix server and agent
dnf:
name:
- zabbix-server-mysql
- zabbix-web-mysql
- zabbix-apache-conf
- zabbix-sql-scripts
- zabbix-selinux-policy
- zabbix-agent
state: present
- name: Configure Zabbix database
mysql_db:
name: zabbixdb
state: present
login_user: root
login_password: "root_password"
become: true
- name: Create Zabbix database user
mysql_user:
name: zabbixuser
password: "password"
priv: zabbixdb.*:ALL
host: localhost
state: present
login_user: root
login_password: "root_password"
become: true
- name: Import Zabbix database schema
shell: zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -u zabbixuser -p"password" zabbixdb
become: true
Steps:
- Install Ansible on your control machine (the machine from which you will run the playbook).
- Configure Ansible to connect to your AlmaLinux 9 server. This typically involves setting up SSH keys for passwordless authentication.
- Create an Ansible playbook (e.g.,
install_zabbix.yml
) with tasks to install Zabbix, configure the database, and set up the web frontend. - Customize the playbook variables (e.g., database passwords, time zone) to match your environment.
- Run the playbook using the command
ansible-playbook install_zabbix.yml
.
These alternative methods provide streamlined and automated approaches to deploying Zabbix 6.4 on AlmaLinux 9, reducing manual configuration and ensuring consistency across deployments. Choosing the right method depends on your specific needs and familiarity with the tools involved.