0% found this document useful (0 votes)
33 views12 pages

Install Zabbix From Source

Uploaded by

Niayesh Shafie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views12 pages

Install Zabbix From Source

Uploaded by

Niayesh Shafie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

How to install Zabbix from source step by step guide

Cyber Security Analyst


February 26, 2024

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.

Steps to install Zabbix from source

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:

1- Preparing the server

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:

• sudo dnf update


• sudo dnf upgrade

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:

• systemctl stop firewalld.service


• systemctl disable firewalld

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.

2- Installing the required software packages

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:

• dnf install httpd httpd-tools


After Apache is installed, you must first start and then enable its service so that it is still active after the
server operating system is rebooted, this is done by entering the following command:

• systemctl enable httpd.service


• systemctl start httpd.service

In the next step, you need to install the MySQL database using the following command:

• dnf install mysql-server

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:

• systemctl enable mysqld.service


• systemctl start mysqld.service

3- Installing the required software dependencies

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:

• dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm


Ø Synchronize packages of a remote DNF repository to a local directory.If the command does not
complete successfully then add --skip-broken at the end.If the command had errors , Remember to add
the remi-release-9.rpm from EPEL.

• dnf module reset php

Ø This command resets the PHP module to its default state.

• dnf module enable php:remi-7.4

Ø Here is a quick how to upgrade default PHP version provided on Fedora, RHEL or Rocky with latest
version 7.4

• dnf install php php-mysqlnd

Ø 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 pgp-zip is a php-library for extended work with ZIP-archives

Ø The php-mcrypt is an interface to the mcrypt cryptographic library, which provides various encryption
algorithms and methods.

Ø The php-json is PHP simple library for managing JSON files

Ø The php-xml is PHP library for managing xml files.

Ø 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.

• dnf install gcc mysql-devel libxml2-devel net-snmp-devel curl-devel unixODBC-devel


OpenIPMI-devel libssh2-devel iksemel-devel openldap-devel

Ø 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 mysql-devel is the mysql development package.


Ø The libxml2-devel allows to manipulate XML files. It includes support to read, modify and write XML
and HTML files. libxml2 is required for virtual machine monitoring.

Ø 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.

• dnf install mariadb-devel

o Note : The mariadb-devel project offers client libraries to enable users to connect from a given
application to MariaDB and MySQL databases.

• dnf install libxml2-devel

o Note : If it was installed successfully before , then skip this command.

• dnf install net-snmp-devel

o Note : If it was installed successfully before , then skip this command.

• dnf --enablerepo=powertools install OpenIPMI-devel

o Note : If it was installed successfully before , then skip this command.

• dnf install libevent-devel

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 Note : If it was installed successfully before , then skip this command.

• dnf install pcre-devel

o Zabbix always compiles with the PCRE library ،The pcre-devel library is a set of functions that
implement regular expression pattern matching.

• dnf install libxml2-devel --nobest

o If libxml2-devel was not installed correctly, then execute this command.

• yum install php-bcmath

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.

4- Installing source compilation tools

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:

• dnf group install "Development Tools"

5- Configuring groups and users

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

6- Creating a home directory for the user (optional)

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:

• mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix


• chown zabbix:zabbix /usr/lib/zabbix

7- Creating a Zabbix database in MySQL

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;

8- Download Zabbix source files

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:

• tar -zxvf zabbix-6.0.23.tar.gz

9- Entering the default data in the database

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;

10- Checking the preparation of Zabbix for the compilation process


At this stage, it should be checked whether all the prerequisites are ready to start the Zabbix
compilation process, for this, enter the following command exactly in the command line:

• ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-


libcurl --with-libxml2 --with-openipmi

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.

11- Start the compilation process

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.

12-Zabbix configuration file settings to communicate with the database

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:

• chown -R apache:apache /var/www/html/zabbix

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:

• edit php.ini in /etc/php.ini


• 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

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy