Zabbix essay: 6.0 LTS source code installation

Open source lies in tossing. There are different views on the good and bad of the source code. Since CentOS 8 has EOL and CentOS 7 still has more than two years, this article is available. However, I hope you can switch to Stream version or other alternative distribution version as soon as possible. It is so convenient to install. Today's article is relatively long and not suitable for novices, In addition, compilation will encounter many problems, which requires some patience.


Article environment

  • CentOS 7.9.2009
  • PHP 7.4
  • Postgresql 13
  • Nginx 1.20

Novice advice

Novices suggest turning off the firewall and SElinux, otherwise it is easy to have problems other than accidents, which can be ignored by veterans.

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
systemctl stop firewalld  && systemctl disable firewalld

Recommended conditions

It is recommended to update the software yum update -y

Install front function software

yum -y install wget vim 

Database part

Since the official requirement of Zabbix 6.0 LTS is postgresql 13, the source of postgresql 13 needs to be imported

yum -y install
sed -i "s@" /etc/yum.repos.d/pgdg-redhat-all.repo

Install postgresql

yum -y install postgresql13-server

Start and initialize the database

/usr/pgsql-13/bin/postgresql-13-setup initdb
systemctl enable postgresql-13
systemctl start postgresql-13

Download source package

cd /tmp 

Unzip package

tar -zxvf zabbix-6.0.0.tar.gz

Create Zabbix users and Zabbix user groups

groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix

Create Zabbix installation directory

mkdir -p /app/zabbix

Unzip the source package

tar -zxvf zabbix-6.0.0.tar.gz
mv zabbix-6.0.0 /app

Start compilation

./configure --prefix=/app/zabbix --enable-server --enable-agent2 --with-postgresql=/usr/pgsql-13/bin/pg_config --with-net-snmp

gcc environmental issues

Postgresql library problem

CentOS 7 will report errors when installing this package, which need to be installed and respectively. The error reports are shown in the following two figures.

Missing net SNMP source problem

The libevent source is missing

Lack of go environment (no problem if it is the first generation agent)

After the above steps, the compilation is completed, as shown in the following figure

It should be noted that agent2 is compiled in this environment. Agent2 adopts the go environment and needs to download some libraries through go. In China, it is impossible to download libraries through go. Therefore, an agent needs to be set, otherwise it will be stuck in the figure below

Overall installation directory

Zabbix 6.0 LTS requires PHP version 7.2.5 or above, and remi source needs to be installed to support PHP 7.0 x

Installing nginx

Create zabbix related profiles


mv /app/ui /app/zabbix
vim /etc/nginx/conf.d/zabbix.conf
server {
        listen          80;
#        server_name;

        root    /app/zabbix/ui;

        index   index.php;

        location = /favicon.ico {
                log_not_found   off;

        location / {
                try_files       $uri $uri/ =404;

        location /assets {
                access_log      off;
                expires         10d;

        location ~ /\.ht {
                deny            all;

        location ~ /(api\/|conf[^\.]|include|locale|vendor) {
                deny            all;
                return          404;

        location ~ [^/]\.php(/|$) {
            fastcgi_pass    unix:/run/php-fpm/zabbix.sock;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_index   index.php;

                fastcgi_param   DOCUMENT_ROOT   /app/zabbix/ui;
                fastcgi_param   SCRIPT_FILENAME /app/zabbix/ui$fastcgi_script_name;
                fastcgi_param   PATH_TRANSLATED /app/zabbix/ui$fastcgi_script_name;

                include fastcgi_params;
                fastcgi_param   QUERY_STRING    $query_string;
                fastcgi_param   REQUEST_METHOD  $request_method;
                fastcgi_param   CONTENT_TYPE    $content_type;
                fastcgi_param   CONTENT_LENGTH  $content_length;

                fastcgi_intercept_errors        on;
                fastcgi_ignore_client_abort     off;
                fastcgi_connect_timeout         60;
                fastcgi_send_timeout            180;
                fastcgi_read_timeout            180;
                fastcgi_buffer_size             128k;
                fastcgi_buffers                 4 256k;
                fastcgi_busy_buffers_size       256k;
                fastcgi_temp_file_write_size    256k;

Modify profile

Start nginx

It is found that the front-end display is 502. It is speculated that PHP FPM is not turned on

systemctl enable php-fpm
systemctl start php-fpm

Access the front end again

View nginx logs

tail -f /var/log/nginx/error.log
vim /etc/php-fpm.d/zabbix.conf
user = apache
group = apache

listen = /run/php-fpm/zabbix.sock
listen.acl_users = apache,nginx
listen.allowed_clients =

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 200

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
systemctl restart php-fpm 

php partial installation

yum -y install php-mbstring php-bcmath php-pgsql php-gd php-xml
systemctl restart php-fpm nginx 

Database configuration and import related files

Create user and database

Import database related files

Modify the postgresql permission file and change the local permission to md5 authentication method

Restart the database. It should be noted that the schema part can be filled in public, as shown in the following figure

The program file path is under, and the configuration file path is under

Description=Zabbix Server

ExecStart=/app/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID

vim /app/zabbix/etc/zabbix_server.conf
systemctl restart zabbix-server zabbix-agent2

Added by twinzen on Tue, 01 Mar 2022 05:40:15 +0200