Install Zabbix From Source
Install Zabbix From Source
One of the most challenging ways to install Zabbix is to install Zabbix from source. In this installation
method, you have to do all the processes that are done automatically in the normal Zabbix installation
manually.
Before writing this article, I searched a lot on the Internet to find a comprehensive guide for installing
Zabbix from source, and finally I did not get a specific and correct result, I decided to give you the entire
installation process that I had successfully done myself I will prepare it in the form of this article, so pay
attention to the steps carefully and do not miss anything.
In my opinion, the process of installing Zabbix from the source code is divided into 13 steps, and at first
you should know these 13 steps and proceed according to them in order not to encounter any
installation problems, these steps include the following:
We do all the steps on Rocky 9 operating system, you can also follow all the steps on Rocky Linux or
RHEL. My personal recommendation is to update the software packages first, so that you don't get into
trouble during the Zabbix configuration process, so enter the following command:
Firewall and SELinux may be a problem for you, we will temporarily disable them and reconfigure them
at the end and after the installation process is complete, enter the following command to disable the
firewall:
To disable SELinux, open the /etc/sysconfig/selinux file and make sure SELINUX=disabled.
Then close the file and exit and reboot the operating system once to apply the changes.
· Note: The mentioned steps are for testing the Zabbix installation from outside the server and if you
have network connections, if you want to test everything locally and you don't want to connect to the
Zabbix graphical interface from outside the operating system, you don't need to do the above steps.
In order for your zabbix to work properly, you need to install Apache web server and MySQL database,
you can install Apache using the following command:
In the next step, you need to install the MySQL database using the following command:
Similar to what we did for the Apache service, we do the same for the MySQL service and start and
enable the service, this is done by entering the following command:
One of the problems you will have while installing Zabbix from the source is that due to not using the
Package Manager, the software dependencies of each software package will not be installed
automatically, and when you compile the source, You will be given an error for each of these
dependencies, I have prepared a list of all the dependencies needed to install Zabbix from the source
and by typing the following commands, in most cases you will not need anything extra to compile. If so,
enter the following commands in the command line:
Ø Here is a quick how to upgrade default PHP version provided on Fedora, RHEL or Rocky with latest
version 7.4
Ø The MySQL native driver for PHP (mysqlnd) is a drop-in replacement for the MySQL Client Library
(libmysql) for the PHP script language
• dnf install php-gd php-zip php-mcrypt php-json php-xml php-gettext php-curl php-intl
Ø The php-gd is a powerful graphics library that allows developers to create and manipulate images on
the fly.
Ø The php-mcrypt is an interface to the mcrypt cryptographic library, which provides various encryption
algorithms and methods.
Ø The php-gettext is a PHP library to import/export/edit gettext from PO, MO, PHP, JS files, etc.
Ø The php-curl allows the user to create the HTTP requests in PHP.
Ø The php-intl is a wrapper for the ICU library, a set of C/C++ and Java libraries that provide Unicode
and Globalization support for software applications.
Ø The gcc is the GNU Compiler Collection includes front ends for C, C++, Objective -C, Fortran, Ada, Go,
and D, as well as libraries for these languages (libstdc++,...).
Ø The net-snmp-devel package contains the development libraries and header files for use with the
NET-SNMP project's network management tools.
Ø The curl-devel library which stands for client URL, is a command line tool that developers use to
transfer data to and from a server. curl is required for virtual machine monitoring and SMTP
authentication.
Ø The unixODBC-devel package contains the development files (headers and libraries) for unixODBC,
which can be used to develop and/or compile C-language applications using ODBC.
Ø The OpenIPMI-devel package contains the development libraries and header files of the OpenIPMI
project.
Ø The libssh2-devel package contains the header files, static libraries and development documentation
for libssh2.
Ø The iksemel-devel package contains the header files, static libraries and development documentation
for iksemel.
Ø The openldap-devel package includes the development libraries and header files needed for
compiling applications that use LDAP.
o Note : The mariadb-devel project offers client libraries to enable users to connect from a given
application to MariaDB and MySQL databases.
o Note : The libevent-devel API provides a mechanism to execute a callback function when a specific
event occurs on a file descriptor or after a timeout has been reached.
• dnf install curl curl-devel
o Zabbix always compiles with the PCRE library ،The pcre-devel library is a set of functions that
implement regular expression pattern matching.
o Note : BCMath stands for Binary Calculator Math, a library in PHP that provides arbitrary precision
arithmetic operations. It is especially useful when dealing with large integers or decimals that exceed
the limits of PHP's native number types (int and float). If you do not install it now , you will get PHP
errors in the future.
Note : Each of the commands you see above is the result of an error that I received when checking the
zabbix files for compilation, and after entering the commands we mentioned, no more errors were
found when checking the compilation. If you don't enter the above commands, you'll need to search for
any errors you get and find and install the offending dependency file.
Note : Installing PHP in the above commands is because the Zabbix user interface is written in this
language, if you do not enter the above commands, you will get errors such as MySQL Error, Lixml12
Error, SNMP Error, OpenIPMI Error, Libevent-devel Error, You will get Curl Error, libpcre Error, etc. I have
made it very easy for you.
Most of the source codes of Zabbix are written in C language and you need code compiler tools to be
able to compile them, in this part you need to install Development Tools so that the code compilation
tools are also installed along with them, for this Just enter the following command:
Zabbix also needs access to run, to provide this access it is necessary to create a group and a user. At
this stage, we create a system group and a system user for Zabbix so that the Zabbix service has the
necessary access to run, for this, you just need to enter the following two commands:
• groupadd --system zabbix
• useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System"
zabbix
System service users usually do not need to have a Home Directory, this part of Zabbix installation from
the source is completely optional. It may sometimes be necessary to store temporary data for the
database or in the form of Temporary files, defining this Home Directory may help you in such
situations, but it is definitely not required. You can do this using the following two commands:
Now it's time to build the Zabbix database in MySQL, for this you just need to enter the following
commands in order:
• mysql –u root -p
• mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
• mysql> create user 'zabbix'@'localhost' identified by 'password';
• mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
• mysql> SET GLOBAL log_bin_trust_function_creators = 1;
• mysql> quit;
Now you need to download the source files of Zabbix, we are using Zabbix version 6.0 here, just enter
the following command to download:
• wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.23.tar.gz
The zipped file of Zabbix is downloaded in the current path. To use the contents of the files, you need to
extract them in the current path, just enter the following command:
When you install Zabbix normally, sample data is registered in its database, this does not happen when
the installation process is installed from the source, and you have to enter the sample data of the
database manually. To do this, first enter the Zabbix source directory and the databases directory, and
then enter the mysql folder and enter the following commands in order:
• cd database/mysql
• mysql -uzabbix -p zabbix < schema.sql
• mysql -uzabbix -p zabbix < images.sql
• mysql -uzabbix -p --default-character-set=utf8mb4 zabbix < data.sql
Currently, your Zabbix database has a series of default data in it. Next, one of the features of MySQL
must be disabled, that is, you must enter the following command in the command line:
• mysql -uroot -p
• mysql> SET GLOBAL log_bin_trust_function_creators = 0;
• mysql> quit;
In order for the command to work correctly, be sure to enter the Zabbix source directory, then enter the
command. By entering the above command, all the dependencies and libraries needed to compile
Zabbix will be checked and if everything runs without problems, you will see the following image:
If you haven't entered the commands we said before correctly, here you will definitely encounter errors
that you need to fix. If you see the message in the image above, Now run make install, that means your
zabbix is ready to be compiled.
Everything is ready to be compiled, just enter the following command to start the compilation process of
the Zabbix source:
• make install
Everything goes smoothly, but this is just the beginning and the main installation process is still going on.
At this stage, you must configure the Zabbix database for both the Agent and the server in the
configuration files, for this we first open the zabbix_agentd.conf file, which is done with the following
command:
• nano /usr/local/etc/zabbix_agentd.conf
Look for the Hostname value in this file and change it to Hostname=rocky-linux.
Then save the file and this time open the zabbix_server.conf file with the following command:
• nano /usr/local/etc/zabbix_server.conf
Look for the following values in this file and change them according to the following information:
• DBName=zabbix
• DBPassword=password
• DBHost=127.0.0.1
Then save the changes and exit the file, then start the Zabbix service and the Zabbix Agent service using
the following command to apply the changes:
• zabbix_server
• zabbix_agentd
13- Transfer the graphic interface files to the Apache web server folder
We don't have anything to do with the Zabbix service anymore, it's time to configure the web server and
view the Zabbix graphical interface. First, you need to create a directory in Apache, which you do with
the following command:
• mkdir /var/www/html/zabbix
Then we enter the directory of the Zabbix sources that we downloaded and enter the ui directory and
move its contents to the directory we created in Apache, this is done with the following two commands:
• cd zabbix-6.0.23/ui/
• cp -a . /var/www/html/zabbix
In order for everything to work well, we must give the Zabbix group and user we created the necessary
access to the folder where the Zabbix contents are located on the web server, this is done with the
following command:
Our work with Zabbix is almost finished, the only thing left is to change the default values of the php.ini
file, which we need to edit using the following command:
Save the file and exit, completely restart the Rocky server once. And after booting the operating system,
you can connect to Zabbix through the IP address of the server using the following address in the
browser and view the graphical interface:
Everything is correct and you have installed Zabbix from source easily with this method. I hope it has
been noticed by you.