There is a new version of this tutorial available for CentOS 8.

How to Install and Configure Zabbix on CentOS 7

Zabbix is an open source monitoring tool for network services, network hardware, servers, and application. Designed to track and monitor the status of your system and servers. Zabbix offers support for many database systems - including MySQL, PostgreSQL, SQLite, and IBM DB2  - to store data. Zabbix backend is written in C, and the frontend is written in PHP.

In this tutorial, we will show you step-by-step how to install and configure an open source monitoring system Zabbix 3.4 on the CentOS 7 system. This guide will cover some topics, including installation and configuration of the LAMP Stack for our Zabbix installation, and how to change the default password for Zabbix admin web UI.

Prerequisites

  • CentOS 7 Server
  • Root privileges

What we will do?

  1. Install Apache2/httpd on CentOS 7
  2. Install and Configure PHP 7.2 on CentOS 7
  3. Install and Configure MySQL
  4. Install and Configure Zabbix 3.4 on CentOS 7
  5. Configure FirewallD
  6. Zabbix Initial-Setup
  7. Change Default Admin

Step 1 - Install Apache2/httpd

In this guide, we will run Zabbix under the Apache web server. The web server packages can be installed from the default CentOS 7 repository.

Install Apache/httpd using the yum command below.

sudo yum -y install httpd

After the installation is complete, start the service and enable it to launch every time at system boot.

systemctl start httpd
systemctl enable httpd

The Apache/httpd web server has been installed on the system - check it using the netstat command.

netstat -plntu

And you will get the default HTTP port 80 in the LISTEN state.

Netstat command

Step 2 - Install and Configure PHP 7.2 on CentOS 7

In this step, we will install PHP 7 from a third-party repository - we will install PHP 7.2 from the 'webtatic' repository.

Before installing PHP 7 with all extensions needed, add the webtatic and the EPEL repository to the system.

Run commands below.

yum -y install epel-release
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Now install PHP 7.2 packages from the webtatic repository using yum.

yum -y install mod_php72w php72w-cli php72w-common php72w-devel php72w-pear php72w-gd php72w-mbstring php72w-mysql php72w-xml php72w-bcmath

And after the installation is complete, we need to edit the default 'php.ini' file using the vim editor.

vim /etc/php.ini

Change the values of the configuration as shown below.

 max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Jakarta

Save and exit.

Now restart the httpd service.

systemctl restart httpd

The PHP 7 installation and configuration for Zabbix has been completed.

Step 3 - Install and Configure MariaDB

Zabbix offers support for many databases for the installation, including MySQL, PostgreSQL, SQLite, and Oracle database. For this guide, we will be using MariaDB as the database for our Zabbix installation.

Install mariadb-server using yum command below.

sudo yum -y install mariadb-server

After the installation is complete, start the service and enable it to launch everytime at system boot.

systemctl start mariadb
systemctl enable mariadb

Now run the command below to configure MariaDB root password.

mysql_secure_installation

Type your root password and press Enter.

Install MariaDB

MariaDB database has been installed, and the root password has been configured.

Next, we need to create a new database for our Zabbix installation. We will create a new database and user named 'zabbix' with password '[email protected]'.

Login to the MySQL shell.

mysql -u root -p

And run the following MySQL queries on the shell.

create database zabbix; 
grant all privileges on zabbix.* to [email protected]'localhost' identified by '[email protected]';
grant all privileges on zabbix.* to [email protected]'%' identified by '[email protected]';
flush privileges;

New database for Zabbix installation has been created.

Create database

Step 4 - Install and Configure Zabbix 3.4

In this step, we will install and configure Zabbix. We will install Zabbix from the official repository, then configure Zabbix-server and Zabbix-agent.

- Install Zabbix Packages

Add the Zabbix repository to the CentOS 7 system.

yum -y install http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm

Now install Zabbix using the yum command below.

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

Wait for the Zabbix packages installation.

Install Zabbix

- Import Database Sample

Import the Zabbix database sample to our 'zabbix' database. Go to the Zabbix documentation directory and extract the Zabbix sql file.

cd /usr/share/doc/zabbix-server-mysql-3.4.6/
gunzip create.sql.gz

Now import the database sample to our 'zabbix' database.

mysql -u root -p zabbix < create.sql

Type your root password and make sure there is no error.

Import the database

- Configure Zabbix Server

Zabbix-server is the central process of the Zabbix software system. We will configure the Zabbix-server by editing the configuration file using the vim editor.

Run the following command.

vim /etc/zabbix/zabbix_server.conf

On the database line configuration, type the configuration as below and change the 'DBPassword' value with your own database password.

DBHost=localhost
[email protected]

Save and exit.

Now start the Zabbix-server service and enable it to launch everytime at system boot.

systemctl start zabbix-server
systemctl enable zabbix-server

Zabbix-server is running on the CentOS 7 system - check it using the command below.

systemctl status zabbix-server

And you will get the result as shown below.

Configure zabbix server

- Configure Zabbix Agent

Zabbix-agent must be installed on the target monitoring system. The agent will gather all information of the server and reports data to the Zabbix-server.

Edit the Zabbix-agent configuration file using vim.

vim /etc/zabbix/zabbix_agentd.conf

Change following lines with your own info:

 Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=hakase-labs

Save and exit.

Now start the zabbix-agent and enable it to launch everytime at system boot.

systemctl start zabbix-agent 
systemctl enable zabbix-agent

Zabbix-agent is running on the system - check it using the following command.

systemctl status zabbix-agent

And you will get the result as shown below.

Configure zabbix agent

Step 5 -  Configure Firewalld

In this step, we will open the HTTP and https port for Zabbix admin web UI, and will also add an additional port for Zabbix-server and Zabbix-agent.

If you do not have firewalld on your system, install it using the following command.

yum -y install firewalld

Start the firewalld service and enable it to launch everytime at system boot.

systemctl start firewalld
systemctl enable firewalld

Now we will open the HTTP and https port, and the port that will be used by the Zabbix-server and Zabbix agent (port 10051 and 10050).

Run the following firewall-cmd commands.

firewall-cmd --add-service={http,https} --permanent
firewall-cmd --add-port={10051/tcp,10050/tcp} --permanent

Now reload the firewalld configuration and check the port.

firewall-cmd --reload
firewall-cmd --list-all

Configure the firewall

Firewalld configuration for Zabbix installation has been completed.

Step 6 - Zabbix Initial Setup

Before going any further, we will restart all of our services using the systemctl commands below.

systemctl restart zabbix-server
systemctl restart zabbix-agent
systemctl restart httpd

Now open your web browser, and type your server IP address.

http://192.168.33.10/zabbix/

And you will be redirected to the Zabbix welcome message.

Zabbix setup

Click the 'Next Step' button.

Now, Zabbix will check all system requirements for its installation. Make sure there is no error.

Check pre-requisites

Then click the 'Next step' button again.

For the database info, type all your database setup.

Configure db

And click the 'Next step' button.

Now comes the Zabbix server details configuration. On the 'Host' field, type your own server IP address, and change the name with your own domain name or hostname.

Server details

Click the 'Next step' button again.

Make sure all of those configurations are correct, then click the next button to install Zabbix.

Installation summary

And when the installation is complete, you will get the page as shown below.

Zabbix successfully installed

Click the 'Finish' button and you will be redirected to the Zabbix login page.

Login with default user 'admin' and password 'zabbix'.

Login to zabbix

Now you get the Zabbix admin Dashboard.

Zabbix dashboard

Zabbix server installation has been completed.

Step 7 - Change Default Admin Password

In this step, we want to change the default Zabbix admin password for security.

On the Zabbix admin dashboard, click the user icon on the top right.

Change Default Admin Password

Click the 'Change Password' button and type your new password.

Change password

Now click the 'update' button, and the default admin password has been changed.

Zabbix monitoring system is now installed on the CentOS 7 server.

Reference

Share this page:

Suggested articles

16 Comment(s)

Add comment

Comments

By: A Hanjrah

Works like a charm! Each and every command is in accordance with CentOS 7. Thank you for this awsome tutorial.

By: Jacob Biblow

Works like a charm!

1. Missing the postfix part for sending notifications via email.

2. there is an error when going to latest data that says: "

count(): Parameter must be an array or an object that implements Countable [ in latest.php:104]

"

 

anyway thank you so much!

By: Andre C

 Works like a charm! Each and every command is in accordance with Amazon LInux as well. Thank you for this awsome tutorial.

By: Gabriel

I have a problem, and I have searched but I have not found the solution.

 

When typing systemctl status zabbix-server the result I get is the following:

 

? zabbix-server.service - Zabbix Server

   Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; enabled; vendor preset: disabled)

   Active: deactivating (sop-sigterm) (Result: exit-code) since Fri 2018-06-22 08:13:48 -04; 1h 5min ago

  Process: 15183 ExecStop = / bin / kill -SIGTERM $ MAINPID (code = exited, status = 1 / FAILURE)

  Process: 15128 ExecStart = / usr / sbin / zabbix_server -c $ CONFFILE (code = exited, status = 0 / SUCCESS)

 Main PID: 15130 (code = exited, status = 0 / SUCCESS)

   CGroup: /system.slice/zabbix-server.service

           ??15151 / usr / sbin / zabbix_server -c /etc/zabbix/zabbix_server.conf

           ??15153 / usr / sbin / zabbix_server -c /etc/zabbix/zabbix_server.conf

 

Jun 22 08:13:48 localhost.localdomain kill [15183]: with the same uid as the present process

Jun 22 08:13:48 localhost.localdomain kill [15183]: -s, --signal <sig> send specific signal

Jun 22 08:13:48 localhost.localdomain kill [15183]: -q, --queue <sig> use sigqueue (2) rather than kill (2)

Jun 22 08:13:48 localhost.localdomain kill [15183]: -p, --pid print pids without signaling them

Jun 22 08:13:48 localhost.localdomain kill [15183]: -l, --list [= <signal>] list signal names, or convert one to a name

Jun 22 08:13:48 localhost.localdomain kill [15183]: -L, --table list signal names and numbers

Jun 22 08:13:48 localhost.localdomain kill [15183]: -h, --help display this help and exit

Jun 22 08:13:48 localhost.localdomain kill [15183]: -V, --version output version information and exit

Jun 22 08:13:48 localhost.localdomain kill [15183]: For more details see kill (1).

Jun 22 08:13:48 localhost.localdomain systemd [1]: zabbix-server.service: control process exited, code = exited status = 1

 

it's diferent.

 

Please, Help me

By: Daniel

I had a similar issue.  Cause is SELINUX for me.  Disabled until i can understand the details...

Here is a clue.

http://d-prototype.com/archives/10737

By: kho

thanks a lot, save time.

but after all the installation done it gives me the error Zabbix server is not running?

how to fix? 

i have added listenIP also

By: Nguy?n M?nh D?ng

First you need to know what causes make your error by using command :vi /var/log/zabbix/zabbix_server.log

After that you can follow intructions below : (in my case I met an error : Cannot bind socket to “/var/run/zabbix/zabbix_server_preprocessing.sock”: [13] Permission denied.)

# getsebool -a | grep zabbix # setsebool -P zabbix_can_network on # systemctl stop mysqld # systemctl stop zabbix-server # systemctl stop zabbix-agent # yum install -y policycoreutils-python # sudo yum install wget # wget -O zabbix_server_add.te https://support.zabbix.com/secure/attachment/53320/53320_zabbix_server_add.te –no-check-certificate # checkmodule -M -m -o zabbix_server_add.mod zabbix_server_add.te # semodule_package -o zabbix_server_add.pp -m zabbix_server_add.mod # semodule -i zabbix_server_add.pp # systemctl restart zabbix-server; # systemctl restart zabbix-agent # systemctl start mysqld # systemctl start zabbix-server # systemctl start zabbix-agent

After install python package you can fix your error!

Hope this help!

By: Tiborg

Hello,

great tutorial!

But I am stuck at some point.

At the Zabbix pre-requisites it gives an error.

PHP option "date.timezone" unknown Fail

Time zone for PHP is not set (configuration parameter "date.timezone")

I already searched in the php file and I used date.timezone = Europe

 

I also changed it to Asia/Jakarta but the error still accurs.

How can I fix this? Thanks in advance.

By: till

Try to set the timezone in php.ini file to this exact line:

date.timezone = "Asia/Jakarta"

and restart apache.

By: Tiborg

Lol, I forgot to remove the ; before the command line date.timezone.

Thank you for the quick answer!

By: Jean Barcelos

Muito obrigado, deu tudo certo.

By: jeff

This instruction set was really good.  The only part i'm having a hard time with is the user access to the database for some reason.

The logs show

 

 29995:20181228:081714.946 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO)

 29995:20181228:081714.946 database is down: reconnecting in 10 seconds

Any suggestions?  Thanks a lot!!

By: Antonin meignan

Works just fine with 4.0.* as well

By: bruc3

If you are get error below when starting "zabbix-server":

cannot start preprocessing service: Cannot bind socket to "/var/run/zabbix/zabbix_server_preprocessing.sock": [13] Permission denied.

Fix is below:

yum install policycoreutils-python

cd ~

curl https://support.zabbix.com/secure/attachment/53320/zabbix_server_add.te > zabbix_server_add.te

checkmodule -M -m -o zabbix_server_add.mod zabbix_server_add.te

semodule_package -m zabbix_server_add.mod -o zabbix_server_add.pp

semodule -i zabbix_server_add.pp

 

 

By: Sara

Hello,

after installing zabbix successfully I am facing this error while opening the Url

date(): Invalid date.timezone value 'Africa/Egypt', we selected the timezone 'UTC' for now. [zabbix.php:21 ? require_once() ? ZBase->run() ? ZBase->processRequest() ? CController->run() ? CControllerDashboardView->doAction() ? calculateTime() ? date() in include/func.inc.php:2610]

By: D Chinthaka

Hi, I set the same parameter and restart apache but the result is same "Time zone for PHP is not set". Any suggestions?