Install and Configure Zabbix 4.0 from Source on Fedora 29/Fedora 28/CentOS 7

|
Last Updated:
|
|

In this guide, we are going to learn how to install and configure Zabbix 4.0 from source on Fedora 29/Fedora 28/CentOS 7.

Zabbix is an enterprise class open-source monitoring solution designed for real time monitoring of networks, servers, virtual machines and cloud sources. It also monitors any possible server performance metrics and incidents such as CPU utilization, memory utilization, Network bandwidth usage, disk space utilization etc.

Zabbix metrics collection method include;

  • Multi-platform Zabbix agent
  • SNMP and IPMI agents
  • Agentless monitoring of user services
  • Custom methods
  • Calculation and aggregation
  • End user web monitoring

Zabbix has an handful of features which you can check them on Zabbix features page.

You can also check out our previous article on Nagios availability monitoring.

Installing Zabbix from Source on Fedora 29/Fedora 28/CentOS 7

Setup LAMP Stack

Zabbix is built around a modern Apache web server, leading database engines such as MySQL and PHP scripting language. Therefore ensure that you have LAMP stack installed before you can proceed.

You can check our previous articles on how to install LAMP stack on Fedora28/29. This will also apply to CentOS 7. If you follow this LAMP stack installation guide, install the following additional PHP extensions.

yum install php-{xml,bcmath,common,pear,gettext,ctype}

Disable SELinux

Disable or set SELinux in permissive mode.

sed -i 's/=enforcing/=permissive/' /etc/selinux/config

or

sed -i 's/=enforcing/=disabled/' /etc/selinux/config

Note that a system reboot is required in order to effect the SELinux changes.

Install required Dependencies

Install the packages dependencies required to compile Zabbix from the source. Note that these dependencies depends on the option you choose to Zabbix from the source

sudo yum -y install gcc make mariadb-devel pcre* libevent-devel libxml2-devel net-snmp-devel libcurl-devel libssh2-devel

Configure Apache Server

Once your system has met the above minimums, as a best practise for securing Zabbix setup, you need to disable Apache web server information exposure. Edit Apache main configuration file, /etc/httpd/conf/httpd.conf, and add the following lines at the end of the file.

ServerSignature Off
ServerTokens Prod

You can simplify the above the above process with the following single line’

echo -e "ServerSignature Off\nServerTokens Prod" >> /etc/httpd/conf/httpd.conf

Set the Apache Server name to your hostname.

ServerName zabbix.example.com

Set PHP Timezone

Edit the /etc/php.ini file and set the appropriate timezone.

sed -i 's/^;date.timezone =/date.timezone = Africa\/Nairobi/' /etc/php.ini

Zabbix Server Backend Configuration

Install Zabbix 4.0 server

There are four ways in which Zabbix can be installed and these include;

  • Install it from the distribution packages
  • Installing from the source archive
  • Install it from the containers
  • Download the virtual appliance

In this tutorial, we are going to install Zabbix 4.0 from the sources.

Download Latest Zabbix Source Archive

To download the latest Zabbix source archive, visit the Zabbix download page and grab it there. Once you have downloaded the archive, extract it as follows;

tar xzf zabbix-4.0.1.tar.gz

Create Zabbix user account

An unprivileged user is required to run all Zabbix processes. Therefore, you need to create a zabbix user account with zabbix group. The user should not have a home directory. This can be done as shown below;

useradd -M zabbix

This will automatically create a zabbix group.

id zabbix
uid=1001(zabbix) gid=1001(zabbix) groups=1001(zabbix)

Create MySQL Database for Zabbix

A database is required for managing and storing Zabbix data. Once the database is created, you are required to import the database schema and dataset as will be shown shortly.

To create Zabbix MySQL database, proceed as follows

mysql -u root -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'STRONGP@SSWORD';
flush privileges;
quit

Import the database schema and data set.

cd zabbix-4.0.1/database/mysql/
mysql -u zabbix -p zabbix < schema.sql
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql

Compile and Install the Zabbix source

Once you are done with database creation, proceed to compile and install Zabbix. Note that you must specify the database type to be used when compiling the sources. For this procedure to succeed, you need to have installed the dependencies mentioned in the prerequisites.

cd ../../
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

If the compilation is successful, you should be able to see the configuration summary as shown below;


...
Configuration:

  Detected OS:           linux-gnu
  Install path:          /usr/local
  Compilation arch:      linux

  Compiler:              cc
  Compiler flags:         -g -O2 

  Library-specific flags:
    database:               -I/usr/include/mysql -I/usr/include/mysql/mysql   
    libXML2:               -I/usr/include/libxml2
    Net-SNMP:               -I. -I/usr/include

  Enable server:         yes
  Server details:
    With database:         MySQL
    WEB Monitoring:        cURL
      SSL certificates:      /usr/local/share/zabbix/ssl/certs
      SSL keys:              /usr/local/share/zabbix/ssl/keys
    Native Jabber:         no
    SNMP:                  yes
    IPMI:                  no
    SSH:                   no
    TLS:                   no
    ODBC:                  no
    Linker flags:             -L/usr/lib64/        -L/usr/lib64         -rdynamic   
    Libraries:               -lmariadb  -lz -ldl -lm -lpthread -lssl -lcrypto     -lxml2    -lnetsnmp   -lz -lpthread -levent    -lcurl -lm -ldl  -lresolv -lpcre 
    Configuration file:    /usr/local/etc/zabbix_server.conf
    External scripts:      /usr/local/share/zabbix/externalscripts
    Alert scripts:         /usr/local/share/zabbix/alertscripts
    Modules:               /usr/local/lib/modules

  Enable proxy:          no

  Enable agent:          yes
  Agent details:
    TLS:                   no
    Linker flags:                -rdynamic   
    Libraries:              -lz -lpthread    -lcurl -lm -ldl  -lresolv -lpcre 
    Configuration file:    /usr/local/etc/zabbix_agentd.conf
    Modules:               /usr/local/lib/modules

  Enable Java gateway:   no

  LDAP support:          no
  IPv6 support:          yes

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

4 thoughts on “Install and Configure Zabbix 4.0 from Source on Fedora 29/Fedora 28/CentOS 7”

  1. getting this error

    The frontend does not match Zabbix database. Current database version (mandatory/optional): 4020000/4020000. Required mandatory version: 3000000. Contact your system administrator.

    Reply

Leave a Comment