Zabbix server on CentOS 7 and SELinux · uwot.eu
another meaningless subtitle

Zabbix server on CentOS 7 and SELinux

· by fabio · Read in about 2 min · (277 Words)
CentOS 7 SELinux Zabbix

Zabbix is an open source resource and network monitoring system, more info: zabbix.com.
The official wiki is missing some important bits regarding the installation of the tool on CentOS 7 systems.
First of all, let’s add Zabbix repository and then proceed to with the installation of Zabbix and some required dependecies:

$ rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
$ yum install mariadb mariadb-server httpd zabbix-server-mysql zabbix-web-mysql setroubleshoot

.:. Configure MariaDB

Login to MariaDB shell, change root’s password, create a new database for Zabbix and add a new user:

$ systemctl start mariadb
$ mysql -u root -p

mariadb> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');
mariadb> create database zabbix character set utf8 collate utf8_bin;
mariadb> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
mariadb> SET PASSWORD FOR 'zabbix'@'localhost' = PASSWORD('password');
mariadb> quit;

Import database schema and default data:

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

.:. Configure Zabbix

Edit Zabbix’s configuration file:

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=<password>

At least on CentOS release version 7.4.1708 the standard SELinux policies for Zabbix prevent zabbix-server from working properly.
The command “sealert -a /var/log/audit/audit.log” can be used to identify the issue and it also propose a method on how to solve it; in my case it was:

$ setsebool -P httpd_can_connect_zabbix on
$ ausearch -c 'zabbix_server' --raw | audit2allow -M my-zabbixserver
$ semodule -i my-zabbixserver.pp

Edit Apache’s configuration and set the correct timezone:/

php_value date.timezone Europe/Riga

Enable and start all the required services:

$ systemctl enable mariadb httpd zabbix-server
$ systemctl start httpd zabbix-server

In order to install the front end of Zabbix navigate to the URL “http://server_ip_or_name/zabbix” and follow the wizard.
.:. Sources
1. Server installation with MariaDB
2. Installing the frontend