Complete Guide to Installing and Configuring Zabbix 5.0 Monitoring System

This guide covers the installation of Zabbix 5.0 using the YUM package manager on CentOS 7. The environment used for this setup includes CentOS Linux release 7.5.1804 with MySQL 5.7.32.

1. Configure Zabbix Repository

First, add the official Zabbix repository to your system:

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
yum makecache fast

2. Install Zabbix Server Components

yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get

If you encounter package conflict errors with the EPEL repository, disable it temporarily:

cd /etc/yum.repos.d/
mv epel.repo epel.repo.bak
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get

3. Install Frontend Dependencies

Enable the Software Collections (SCL) repository for PHP 7.2 support:

yum -y install centos-release-scl

Edit the Zabbix repository configuration to enable the frontend repository:

vi /etc/yum.repos.d/zabbix.repo

Set enabled=1 in the [zabbix-frontend] section:

[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

4. Install Frontend Packages

yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl

MySQL Database Setup

1. Install MySQL 5.7

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum -y install yum-utils
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community
yum install mysql-community-server -y

Alternatively, for a binary installation:

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
tar zxvf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -s mysql-5.7.32-linux-glibc2.12-x86_64 mysql

2. Initialize and Start MySQL

/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start

3. Create Zabbix Database and User

mysql -u root -p

Execute the following SQL commands:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourStrongPassword';
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'ZabbixDBPass';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
FLUSH PRIVILEGES;
QUIT;

4. Import Initial Schema

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p'ZabbixDBPass' zabbix

Zabbix Server Configuration

1. Configure Database Connection

Edit the server configuration file:

vi /etc/zabbix/zabbix_server.conf

Update the following parameters:

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=ZabbixDBPass
DBPort=3306

2. Configure PHP Timezone

Edit the PHP-FPM configuration for Zabbix:

vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

Set the timezone:

php_value[date.timezone] = Asia/Shanghai

3. Fix Font Display for Graphs

To prevent Chinese characters from appearing as boxes in graphs:

yum -y install wqy-microhei-fonts
mv /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf.bak
cp -f /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

4. Start Services

systemctl restart zabbix-server httpd rh-php72-php-fpm
systemctl enable zabbix-server httpd rh-php72-php-fpm

Access the web interface at http://SERVER_IP/zabbix to complete the setup wizard. Default credentials are Admin/zabbix.

Agent Installation and Configuration

1. Install Zabbix Agent

yum install zabbix-agent -y

2. Configure Agent

Edit the agent configuration file:

vi /etc/zabbix/zabbix_agentd.conf

Configure the essential parameters:

Server=YOUR_ZABBIX_SERVER_IP
ListenPort=10050
Hostname=agent-node-01
Include=/etc/zabbix/zabbix_agentd.d/*.conf

3. Start the Agent

systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service

Custom Monitoring Scripts

1. Define Custom User Parameters

Create a configuration file for custom checks:

vi /etc/zabbix/zabbix_agentd.d/custom_checks.conf

Add your custom parameter definitions:

UnsafeUserParameters=1
UserParameter=service.status[*],/etc/zabbix/scripts/check_service.sh $1

2. Create the Monitoring Script

vi /etc/zabbix/scripts/check_service.sh

Example script to check if a Java service is running:

#!/bin/bash

SERVICE_NAME=$1

PROCESS_COUNT=$(ps aux | grep "${SERVICE_NAME}" | grep -v grep | grep java | grep -v "$0" | wc -l)

if [ "${PROCESS_COUNT}" -eq 1 ]; then
    echo "1"
else
    echo "0"
fi

Make the script executable:

chmod +x /etc/zabbix/scripts/check_service.sh
systemctl restart zabbix-agent.service

Email Alert Configuration

1. Configure Media Type

Navigaet to Administration → Media types → Email. Configure SMTP settings using your email provider's credentials. For services like 163.com, use the authorization code instead of your password.

2. Configure User Alert Settings

Go to Administration → Users → Admin → Media. Add your email address and set the appropriate alert severtiy levels.

3. Create Alert Action

Navigate to Configuration → Actions → Trigger actions. Create a new action with the following message templates:

Default message:

Problem: {TRIGGER.NAME}
Host: {HOSTNAME1}
IP: {HOST.CONN}
Time: {EVENT.DATE} {EVENT.TIME}
Severity: {TRIGGER.SEVERITY}
Details: {ITEM.NAME}: {ITEM.VALUE}
Event ID: {EVENT.ID}

Recovery message:

Resolved: {TRIGGER.NAME}
Host: {HOSTNAME1}
IP: {HOST.CONN}
Recovery Time: {EVENT.DATE} {EVENT.RECOVERY.TIME}
Details: {ITEM.NAME}: {ITEM.VALUE}

Web Monitoring Setup

1. Create Web Scenario

Go to Configuration → Hosts → Select Host → Web. Create a new scenario with HTTP check steps pointing to your monitored URL.

2. Configure Trigger for Web Monitoring

Create a trigger based on the web scenario status:

{host:web.test.fail[ScenarioName].last()}>0

Port Monitoring

1. Create Port Check Item

In the host configuration, create a new item using the net.tcp.listen key:

net.tcp.listen[90]

2. Create Trigger for Port Check

Define a trigger that fires when the port is not listening:

{host:net.tcp.listen[90].last()}=0

Posted on Thu, 14 May 2026 00:47:36 +0000 by aswini_1978