How To Set up and Configure Zabbix on Centos 7

In this article, we want to teach you How To Set up, Install and Configure Zabbix on Centos 7.

Zabbix is defined as an open-source monitoring tool used for monitoring servers, networks, IT components, cloud services, and virtual machines. The Zabbix monitoring tool is used to provide the monitoring metrics and monitor the network utilization, consumption of disk space, and CPU load.

The tool supports various operating systems like Mac OS, Solaris, Linux, and many more. It uses a different database to store the data and monitor the applications. The Zabbix monitoring tool is developed in C programming language, and PHP language is used for the web front.

Steps To Set up and Configure Zabbix on Centos 7

Before you start to set up Zabbix on Centos 7, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with Centos 7.

Also, you need to set up a basic firewall. To do this, you can follow our article How To Set up a Firewall with firewalld on Centos 7.

Now you can follow the steps below to complete this guide.

Install Required Packages for Zabbix on Centos 7

Update your local package index with the command below:

sudo yum -y update

To install Zabbix, you need some required packages and dependencies.

First, you need to disable the SELinux on Centos 7.

Open the SELinux configuration file with your favorite text editor, here we use vi:

sudo vi /etc/sysconfig/selinux

Find the SELinux directive and change it to disabled as shown below:

SELINUX=disabled

For more information, you can visit this guide on How To Disable SELinux on Centos 7.

When you are done, save and close the file and reboot the system.

reboot

Then, you need to install the required repositories on Centos 7:

sudo yum -y install epel-release
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Install Apache on Centos 7

Now you need to install the Apache webserver on Centos 7 with the command below:

sudo yum -y install httpd

Start and enable the apache service to start on boot on Centos 7 with the following commands:

sudo systemctl start httpd.service
sudo systemctl enable httpd

You can verify your Apache installation on Centos 7 with the command below:

sudo systemctl status httpd.service
Output
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2022-02-26 04:00:26 EST; 12s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 22247 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"

Install PHP on Centos 7

First, you need to disable the PHP 5 repositories and enable the PHP 7.2 repo with the following commands:

sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php72

Then, use the command below to install PHP and its dependencies:

sudo yum install php php-pear php-cgi php-common php-mbstring php-snmp php-gd php-pecl-mysql php-xml php-mysql php-gettext php-bcmath

Here you need to modify the PHP time Zone by editing the php.ini file.

sudo vi /etc/php.ini

At the file, uncomment the following line and add your timezone:

date.timezone = America/New_York

When you are done, save and close the file.

Install Zabbix on Centos 7

To install the latest release of Zabbix on Centos 7, you need to check the latest version of Zabbix from its official site.

First, enable the software collection repository on CentOS 7:

yum install -y centos-release-scl

Then, add the Zabbix repository on your server by using the command below:

sudo rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

Now you can install Zabbix on Centos 7:

sudo yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl zabbix-server-mysql zabbix-agent --enablerepo=zabbix-frontend

Also, to begin using Apache with the Zabbix server. The Zabbix configuration file needs to be updated with TimeZone.

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

Update the below line with your time zone.

php_value[date.timezone] = America/New_York

When you are done, save and close the file.

Install MariaDB on Centos 7

Install MariaDB service on Centos 7 with the command below:

sudo yum --enablerepo=remi install mariadb-server

Start and enable MariaDB to start on boot with the commands below:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb

Now run the command below to secure your MariaDB service on Centos 7:

mysql_secure_installation

You will be asked some questions. Add a new root password and continue. From there press Y.

Then, log in to your MariaDB console on Centos 7:

mysql -u root -p

Enter the root password that you have created, you will see the MariaDB shell:

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

At this point, you need to create a database for Zabbix.

From your MariaDB console, run the following command to create the Zabbix database on Centos 7. You can choose your desired name, here we choose zabbixdb:

Create database zabbixdb;

Next, you need to create a database user and grant all the privileges to it with the commands below:

create user 'zabbixuser'@'localhost' identified BY 'password';
grant all privileges on zabbixdb.* to zabbixuser@localhost ;

Flush the privileges and exit from your MariaDB console:

flush privileges;
exit;

Once you are done creating the database for Zabbix installation, then import the initial schema and data to the newly created database:

# cd /usr/share/doc/zabbix-server-mysql*/
# zcat create.sql.gz | mysql -u zabbixuser -p zabbixdb

At this point, you need to update the database configuration file.

Open the file with your favorite text editor, here we use vi:

sudo vi /etc/zabbix/zabbix_server.conf

Make sure you set it as follows.

DBHost=localhost
DBName=zabbixdb
DBUser=zabbixuser
DBPassword=password

When you are done, save and close the file.

Restart all your services on Centos 7:

sudo systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm

Then, enable the services to start on boot:

sudo systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

Configure Firewall for Zabbix

At this point, we assumed that you have enabled firewalld. Now you need to configure the firewall to allow the Zabbix agent to reach the Zabbix server with the following commands:

# sudo firewall-cmd --permanent --add-port=10050/tcp
# sudo firewall-cmd --permanent --add-port=10051/tcp
# sudo firewall-cmd --permanent --add-port=80/tcp

Then, reload the firewall to apply the new rules:

sudo firewall-cmd --reload

Access Zabbix Web Interface

At this point, you can continue your Zabbix installation from the web interface. Type your server’s IP address in your web browser followed by Zabbix:

http://server-ip/zabbix

Now follow the steps below to complete the Zabbix setup on Centos 7.

Click Next Step on Zabbix welcome page.

Zabbix welcome screen

The next step verifies all the prerequisites are met for Zabbix Installation. If there are any issues, those need to be fixed. Click on the Next Step.

check for pre-installation of Zabbix

In the next screen, Enter the Zabbix database name, DB user, and password. Click the Next Step.

Configure Zabbix DB connection

After that, mention the Zabbix server details, port number, and the name for Zabbix installation, and then click the next step.

Zabbix server details

You will get a pre-installation summary like below. Click the Next step.

Now, you have completed the installation of Zabbix. Click the Finish.

Complete Zabbix installation on Centos 7

When you have clicked on Finish, the installer will redirect you to the Zabbix web console.

Here you can access your Zabbix dashboard.

Log in with the Zabbix default username and password.

Username: Admin

Password: zabbix

Zabbix login screen

You will see your Zabbix dashboard:

Zabbix dashboard on Centos 7

Conclusion

At this point, you learn to Set up and Configure Zabbix on Centos 7.

Hope you enjoy it.

You may be interested in these articles:

Install and Configure Zabbix on AlmaLinux 9

Install and Configure Zabbix 6.0 on Rocky Linux 8

How To Install and Configure Zabbix 6.0 on Debian 11

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *

Stay informed and not overwhelmed, subscribe now!