This guide will walk you through the steps to install and configure Zabbix 4.4 server on a CentOS 8 machine. These steps can also be applied if you are running an earlier version of CentOS or RHEL 7.
Prerequisites
You will need one CentOS/RHEL 8 (physical or virtual) machine with minimal installed having root user privileges.
Disabling SELinux
You should change from SELINUX=enforcing to SELINUX=disable in /etc/selinux/config file for smooth installation of the packages:
vi /etc/selinux/config
SELINUX=disabled
Save and close.
Now reboot your CentOS/RHEL machine to take changes into effect:
reboot
Installing EPEL Repository
It is recommended to install extra packages for enterprise linux repository before installing packages on your CentOS or RHEL:
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
ARCH=$( /bin/arch )
dnf config-manager --set-enabled PowerTools
If you are on RHEL 8 then execute the following command as well:
subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms"
Adding Zabbix Repository
Zabbix isn't available in yum package manager by default, so you will need to install Zabbix official repository on your CentOS or RHEL 8:
yum -y install http://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
Installing Apache
You can install the latest version of apache by typing the following command:
yum -y install httpd httpd-devel
Installing MySQL
You will need to install MySQL database using the following command:
yum -y install mysql-server mysql
Starting Services
Now start Apache and MySQL service and make them persistent even when system reboots:
systemctl start httpd
systemctl start mysqld
systemctl enable httpd
systemctl enable mysqld
Securing MySQL
By default MySQL database is not secure and anyone can intrude into your database, so make it secure by executing the following script and follow the instruction:
mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Please set the password for root here.
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
Installing Zabbix
Now you can install the Zabbix server and web frontend with MySQL database using the following command:
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf
You will also need to install Zabbix agent to collect data about the Zabbix server itself:
yum -y install zabbix-agent
Configuring MySQL
At this stage you will need to create a user and a database for Zabbix like below.
mysql -u root -p
create database zabbix character set utf8;
create user 'zabbix'@'localhost' identified by 'TypeYourPasswordHere';
grant all privileges on zabbix.* to 'zabbix'@'localhost';
flush privileges;
quit;
Importing Zabbix Schema
Find out the Zabbix database schema file and then import it into your newly created database:
find / -name create.sql.gz
Output/usr/share/doc/zabbix-server-mysql/create.sql.gzNow import this schema file into database like below:
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -u zabbix -p zabbix
Credential Settings:
Now edit the
/etc/zabbix/zabbix_server.conf file, uncomment by removing
# and update the following parameter with your zabbix database user password:
vi /etc/zabbix/zabbix_server.conf
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=TypeYourPasswordHere
Save and close.
Configuring PHP
The Zabbix installation process created an PHP configuration file that contains PHP settings. It is located in the directory /etc/php-fpm.d/. You just need to uncomment date.timezone parameter and update it with your timezone. You can check supported time zones on http://php.net/manual/en/timezones.php to find the right one for you.
vi /etc/php-fpm.d/zabbix.conf
[zabbix]
user = apache
group = apache
listen = /run/php-fpm/zabbix.sock
listen.acl_users = apache,nginx
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000
php_value[date.timezone] = Asia/Karachi
Save and close.
Now restart Apache and PHP service to take changes into effect.
systemctl restart httpd
systemctl restart php-fpm
systemctl enable php-fpm
Starting Zabbix Service
Its time to start Zabbix server and make it persistent even when system reboots:
systemctl start zabbix-server
systemctl enable zabbix-server
systemctl start zabbix-agent
systemctl enable zabbix-agent
Check the Zabbix server status before proceeding to next step.
systemctl status zabbix-server
Output:
● zabbix-server.service - Zabbix Server
Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2019-12-18 10:38:36 PKT; 4s ago
Process: 15167 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 15169 (zabbix_server)
Tasks: 38 (limit: 11513)
Memory: 38.1M
CGroup: /system.slice/zabbix-server.service
The Zabbix server status shows up and running, so lets proceed to next step.
Adding Firewall Rules
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload
Configuring Zabbix
The Zabbix web interface lets us see reports and add network devices that you wish to monitor, but it needs some initial setup before we can use it. Open up your web browser and navigate to http://Your_Server_IP/zabbix
The first screen like below will greet you a welcome message.
Click Next step to continue.
This page will show you the table that lists all of the prerequisites to run Zabbix. If anything missing make sure to fix it first then proceed to Next.
Provide zabbix database user password and proceed to next.
Keep it default and proceed next.
This is the summary screen, verify and proceed next.
This screen confirms that you have successfully installed Zabbix.
Click Finish
Zabbix frontend is ready! The default user name is
Admin, password
zabbix.
Once logged in, you will see below dashboard screen and from here you can administer and manage your Zabbix server.
![]()
Installing Zabbix Agent
In this step we will show you how to install and configure Zabbix agent 4.4 on a CentOS, RHEL, Ubuntu and Windows machine.
For CentOS/RHEL 7
yum -y install http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum -y install zabbix-agent
Now edit
/etc/zabbix/zabbix_agentd.conf file and update the
Server= parameter with your zabbix server IP
vi /etc/zabbix/zabbix_agentd.conf
### Option: Server
# List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies.
# Incoming connections will be accepted only from the hosts listed here.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally
# and '::/0' will allow any IPv4 or IPv6 address.
# '0.0.0.0/0' can be used to allow any IPv4 address.
# Example: Server=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com
#
# Mandatory: yes, if StartAgents is not explicitly set to 0
# Default:
# Server=
Server=Your_Zabbix_Server_IP
Save and close.
systemctl restart zabbix-agent
For CentOS/RHEL 8
yum -y install http://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
yum -y install zabbix-agent
Now edit
/etc/zabbix/zabbix_agentd.conf file and update the
Server= parameter with your zabbix server IP
vi /etc/zabbix/zabbix_agentd.conf
### Option: Server
# List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies.
# Incoming connections will be accepted only from the hosts listed here.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally
# and '::/0' will allow any IPv4 or IPv6 address.
# '0.0.0.0/0' can be used to allow any IPv4 address.
# Example: Server=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com
#
# Mandatory: yes, if StartAgents is not explicitly set to 0
# Default:
# Server=
Server=Your_Zabbix_Server_IP
Save and close.
systemctl restart zabbix-agent
For Ubuntu 16
sudo dpkg -i http://repo.zabbix.com/zabbix/4.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.4-1%2Bxenial_all.deb
sudo apt-get install zabbix-agent
Now edit
/etc/zabbix/zabbix_agentd.conf file and update the
Server= parameter with your zabbix server IP
sudo nano /etc/zabbix/zabbix_agentd.conf
### Option: Server
# List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies.
# Incoming connections will be accepted only from the hosts listed here.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally
# and '::/0' will allow any IPv4 or IPv6 address.
# '0.0.0.0/0' can be used to allow any IPv4 address.
# Example: Server=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com
#
# Mandatory: yes, if StartAgents is not explicitly set to 0
# Default:
# Server=
Server=Your_Zabbix_Server_IP
Save and close.
sudo service zabbix-agent restart
For Ubuntu 18/19
sudo dpkg -i http://repo.zabbix.com/zabbix/4.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.4-1%2Bbionic_all.deb
sudo apt-get install zabbix-agent
Now edit
/etc/zabbix/zabbix_agentd.conf file and update the
Server= parameter with your zabbix server IP
sudo nano /etc/zabbix/zabbix_agentd.conf
### Option: Server
# List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies.
# Incoming connections will be accepted only from the hosts listed here.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally
# and '::/0' will allow any IPv4 or IPv6 address.
# '0.0.0.0/0' can be used to allow any IPv4 address.
# Example: Server=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com
#
# Mandatory: yes, if StartAgents is not explicitly set to 0
# Default:
# Server=
Server=Your_Zabbix_Server_IP
Save and close.
sudo systemctl restart zabbix-agent
For Windows
Zabbix Windows agent can be installed from Windows MSI installer packages (32-bit or 64-bit) available for
download:
To install, double-click the downloaded MSI file.
Click Next
Accept the licence to proceed to the next step.
Specify the following parameters and click next.
Click next
Click install
Click finish
Zabbix components along with the configuration file is now installed in a Zabbix Agent folder in Program Files. zabbix_agentd.exe will be set up as Windows service with automatic startup.
Adding Devices to Zabbix Server
When you are done installing Zabbix agent on your Linux or Windows machines, go back to your Zabbix server web interface and start creating devices to monitor them.
Navigate to
Configuration tab
Click
Hosts then click
Create hostThis is our Windows 10 zabbix agent machine. Specify the following parameters according to yours and click
AddClick Templates and add the templates according to your need.
When done adding hosts, navigate back to
Dashboard and there you can see number of hosts you have added in zabbix server to monitor.
Navigate to
Graphs, select your host and graph from the drop down list and see if your host monitoring data is being collected like below.
This is how you can add and monitor your Windows and Linux machines in zabbix server. For the devices like switches, routers, firewall etc, of course you can not install zabbix agent, but you can add and monitor them in zabbix server via SNMP and IPMI interface.
Wrapping up
In this tutorial, you set up a simple and secure solution which will help you monitor your servers. It can now warn you of problems, and you have the opportunity to plot some graphs based on the obtained data so you can analyze it and plan accordingly.