How to Install Zabbix Server 4.0 on CentOS 7

(: February 24, 2019)

Welcome to our guide on how to install Zabbix Server 4.0 on CentOS 7 Server. Our previous guide was on the installation of How to Install Zabbix Server 4.0 on Ubuntu 18.04 & Ubuntu 16.04 LTS. Zabbix is a powerful open source monitoring solution used to monitor server applications, systems, Network devices, Hardware appliances, IoT devices, e.t.c. Its backend is written in C and Java while the user web interface written in PHP.

Zabbix Architecture (Server & Client)

Zabbix works in a Client/Server model. The server communicates to the native software agents available for various Operating systems like Linux, NIX, and Windows. For systems without an agent, generic monitoring protocols such as Simple Network Management Protocol (SNMP) or Intelligent Platform Management Interface (IPMI) can be used.

Install Zabbix Server 4.0 on CentOS 7

Zabbix Server depends on the following software applications:{text-align:left} img{margin:0 auto 0 0}
  • Apache web server
  • PHP with required extensions
  • MySQL/ MariaDB database server

MySQL or MariaDB can be a remote server, but php and httpd need to be installed on the Zabbix server. It is possible to run Apache web server in reverse proxy mode.

It is recommended to have SELinux in permissive mode unless you know how to fix its issues

setenforce 0 sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
cat /etc/selinux/config | grep SELINUX=

Step 1: Install and Configure Apache httpd server

Install Apache web server on CentOS 7 server by running the command:

sudo yum -y install httpd vim

After installing Apache, configure basic security by allowing Prod ServerTokens only on./etc/httpd/conf/httpd.conf Add the following line at the end of the file:

ServerSignature Off
ServerTokens Prod

The directive ServerTokens configures what is returned as the Server HTTP response. Valid options are Full | OS | Minimal | Minor | Major | Prod.

Set ServerName:

# grep ServerName /etc/httpd/conf/httpd.conf

Set Server Admin to receive an email in case of issues.

# grep ServerAdmin /etc/httpd/conf/httpd.conf
ServerAdmin [email protected]

Restart apache web service after making the changes

sudo systemctl restart httpd

If  you have a firewalld firewall installed and enabled, allow access to port 443 and 80

PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologiessudo firewall-cmd --reload

Step 2: Install and Configure PHP

Install PHP on your CentOS 7 server and extensions required by Zabbix.

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

Configure Apache and PHP on CentOS 7

Check PHP installed version:

$ php -v
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Set PHP timezone

sudo sed -i "s/^;date.timezone =$/date.timezone = "Africa/Nairobi"/" /etc/php.ini

Restart httpd after this change:

sudo systemctl restart httpd

Step 3: Install MariaDB Database server

Install MariaDB database server on CentOS 7 server using our guide:

How to Install MariaDB 10.x on Ubuntu 18.04 and CentOS 7

Once Database server is installed, you need to create a database for Zabbix user:

export zabbix_db_pass="StrongPassword"
mysql -uroot -p <<MYSQL_SCRIPT
    create database zabbix;
    grant all privileges on zabbix.* to [email protected]'localhost' identified by '${zabbix_db_pass}';

Replace “StrongPassword” with your desired password for the database.

Step 4: Install Zabbix 4.0 Server on CentOS 7

Now that we have required dependencies installed and working, we can finalize our installation by deploying Zabbix 4.0 server.

Add Zabbix 4.0 repository:

sudo yum install -y

Now install Zabbix 4.0 Server and frontend with MySQL support:

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

Substitute ‘mysql’ in the commands with ‘pgsql‘ to use PostgreSQL, or with ‘sqlite3‘ to use SQLite3 (proxy only).

Import Zabbix Server database schema

For Zabbix server and Zabbix proxy daemons, a database is required. It is not needed to run Zabbix agent. If Zabbix server and proxy are installed on the same host, their databases must be created with different names!

Import initial schema and data for the server with MySQL:

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

Enter your Zabbix database user password when prompted.

With PostgreSQL:

zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u <username> psql zabbix

Step 5: Configure and start Zabbix server

Edit your Zabbix configuration file  /etc/zabbix/zabbix_server.conf and set database connection settings.


Restart Zabbix server after modifying this file:

sudo systemctl restart httpd zabbix-server
sudo systemctl enable zabbix-server

Zabbix Frontend configuration

Apache configuration file for Zabbix frontend is located in /etc/httpd/conf.d/zabbix.conf. Some PHP settings are already configured. But it’s necessary to uncomment the “date.timezone” setting and set the right timezone for you.

php_value date.timezone Africa/Nairobi

Complete settings should be like this:

php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_sizoe 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value max_input_vars 10000

Configure Firewall

If you have ufw firewall installed and running on your system, ensure you allow port 5000 and port 5001

sudo firewall-cmd --add-port={10051/tcp,10050/tcp} --permanent
sudo firewall-cmd --reload

Restart httpd and start frontend installation

sudo systemctl restart httpd

Step 6: Perform Zabbix initial setup

Access “http://(Zabbix server’s hostname or IP address)/zabbix/”  to begin Zabbix initial setup.

Step 1 is a welcome page, click “Next step” to proceed.

Confirm that all pre-requisites are satisfied.

Configure DB settings

Confirm Hostname and Port number for Zabbix server. It is okay to use localhost in place of a name.

Verify all settings and click Next step to finish the initial setup. If all goes well, you should get congratulations page. Click the Finish button to end installation.

You’ll then get the login page. Default logins are:

Username: "admin"
Password: "zabbix"

Dashboard for Zabbix server 4.0 looks like below

Step 6: Change Admin Password

Login to Zabbix admin dashboard with admin user and password zabbix. You need to change the password for admin user after the first login for security reasons.

Navigate to Administration > Users > Admin > Password > Change Password

Configure Monitoring Target host

Now that we have our Zabbix server ready for monitoring, you can start configuring first monitoring target host. By default, Zabbix server is added to monitoring.

To add other host devices, login to Zabbix admin dashboard with the username admin and click on Configuration > Hosts. 

After a few minutes, monitoring data will start flowing in, to check host graphs go to Monitoring > Screens > Server name. My next article will cover the installation of Zabbix agent 4.0 on CentOS 7.{text-align:left} img{margin:0 auto 0 0}

Related Posts