How to Install and Configure Zabbix Server 6 on Ubuntu 22.04

Zabbix is an open-source monitoring software tool for diverse IT components, including networks, servers, virtual machines and cloud services. Zabbix provides monitoring metrics, among others network utilization, CPU load and disk space consumption. Zabbix has a rich set of features to enable users to monitor more than just hosts, offering great flexibility to administrators when it comes to choosing the most suitable option for each situation.

Zabbix uses XML based template which contains elements to monitor. The backend of Zabbix is written in C programming and PHP is used for the web frontend. Zabbix can send you alerts to notify the different events and issues based on metrics and thresholds defined for your IT environment. It supports agent-based and agentless monitoring. But Zabbix agents installation can help you to get detailed monitoring e.g. CPU load, network, disk space utilization.

As of the writting of this article, the latest Zabbix version is 6.0. In this guide, we will learn how to install and configure Zabbix on Ubuntu 22.04.

Related content:

# Ensure that the server packages are up to date

Before proceeding, let us make sure that our server packages are up to date with this command:

1
2
sudo apt update
sudo apt -y upgrade

Let us also install some common packages that we will need

1
sudo apt install -y vim

# Install Mariadb

Zabbix requires mysql to function. Mariadb is a popular Opensource relational management system. We will use it in this guide. It is available in the default repositories as mariadb-server. For a detailed guide check out How to install and Configure Mariadb 10 in Ubuntu 22.04.

Install Mariadb :

1
sudo apt install -y mariadb-server

Once mariadb is installed, you can confirm the details using this command:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
$ apt-cache policy mariadb-server
mariadb-server:
  Installed: 1:10.6.7-2ubuntu1.1
  Candidate: 1:10.6.7-2ubuntu1.1
  Version table:
 *** 1:10.6.7-2ubuntu1.1 500
        500 http://europe-west1.gce.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages
        100 /var/lib/dpkg/status
     1:10.6.7-2ubuntu1 500
        500 http://europe-west1.gce.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages

The Service will be started by default. Confirm the status with this command:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.6.7 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-10-20 18:48:44 UTC; 18s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 104565 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 104566 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 104568 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
    Process: 104607 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 104609 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 104597 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 11 (limit: 4392)
     Memory: 56.9M
        CPU: 594ms
     CGroup: /system.slice/mariadb.service
             └─104597 /usr/sbin/mariadbd

Oct 20 18:48:44 unstable-ubuntusrv mariadbd[104597]: Version: '10.6.7-MariaDB-2ubuntu1.1'  socket: '/run/mysqld/mysqld.sock'  port: 3306  Ubuntu 22.04
Oct 20 18:48:44 unstable-ubuntusrv systemd[1]: Started MariaDB 10.6.7 database server.
Oct 20 18:48:44 unstable-ubuntusrv /etc/mysql/debian-start[104611]: Upgrading MySQL tables if necessary.
Oct 20 18:48:44 unstable-ubuntusrv /etc/mysql/debian-start[104614]: Looking for 'mysql' as: /usr/bin/mysql
Oct 20 18:48:44 unstable-ubuntusrv /etc/mysql/debian-start[104614]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Oct 20 18:48:44 unstable-ubuntusrv /etc/mysql/debian-start[104614]: This installation of MariaDB is already upgraded to 10.6.7-MariaDB.
Oct 20 18:48:44 unstable-ubuntusrv /etc/mysql/debian-start[104614]: There is no need to run mysql_upgrade again for 10.6.7-MariaDB.
Oct 20 18:48:44 unstable-ubuntusrv /etc/mysql/debian-start[104614]: You can use --force if you still want to run mysql_upgrade
Oct 20 18:48:44 unstable-ubuntusrv /etc/mysql/debian-start[104622]: Checking for insecure root accounts.
Oct 20 18:48:44 unstable-ubuntusrv /etc/mysql/debian-start[104628]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables

To ensure that mariadb starts on boot, enable it with this systemd command:

1
sudo systemctl enable mariadb

Once the mysql service is running, you need to secure it. Mysql provides a commandline utility that will do that:

1
sudo mysql_secure_installation

The above command will take you through prompts to secure and set a root password for the mysql instance.

To confirm the version of MariaDB installed, run the command:

1
2
$ mysql -V
mysql  Ver 15.1 Distrib 10.3.32-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

# Create mysql user for Zabbix

We are going to create a dedicated user for zabbix. Check out this guide on managing mysql permissions here.

Connect to mysql server:

1
mysql -u root -p

After Supplying your root password, enter the following to the mysql prompt:

1
2
3
create database zabbix character set utf8 collate utf8_bin;
create user 'zabbix_user'@'%' identified by 'S0mStrongPa$$word';
grant all privileges on zabbix.* to 'zabbix_user'@'%';

Save the username, db name and password, we will need them later.

Now that we have configured our mysql connection, let’s go to the next section where we install and configure PHP.

# Install PHP and required php modules

Zabbix server uses PHP. We need to install and configure PHP for zabbix to work.

To install PHP and the required PHP modules for Zabbix installation:

1
2
3
4
5
6
7
sudo apt install -y \
    php \
    php-cli \
    php-common \
    php-fpm \
    php-curl \
    php-mysqlnd

Check php version

1
2
3
4
5
$ php -v
PHP 8.1.2 (cli) (built: Aug  8 2022 07:28:23) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

For more info on setting up PHP and Apache, check out this guide How to install and set up PHP and Apache(LAMP stack) on Ubuntu 22.04.

# Install Apache Web Server

Next, let us install Apache in our system. Use this command to install Apache web server.

1
sudo apt install -y apache2

Apache 2 will be started by default. Check the status using this command:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-10-20 18:50:48 UTC; 3min 36s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 113972 (apache2)
      Tasks: 34 (limit: 4392)
     Memory: 34.9M
        CPU: 308ms
     CGroup: /system.slice/apache2.service
             ├─113972 /usr/sbin/apache2 -k start
             ├─114005 /usr/sbin/apache2 -k start
             ├─114006 /usr/sbin/apache2 -k start
             ├─114007 /usr/sbin/apache2 -k start
             ├─114008 /usr/sbin/apache2 -k start
             ├─114009 /usr/sbin/apache2 -k start
             └─114010 /usr/sbin/apache2 -k start

Oct 20 18:50:47 unstable-ubuntusrv systemd[1]: Starting The Apache HTTP Server...
Oct 20 18:50:48 unstable-ubuntusrv systemd[1]: Started The Apache HTTP Server.

Active: active (running) indicate that the service is now up and running.

To enable the service on boot, use this command:

1
sudo systemctl enable apache2

# Edit PHP and php-fpm Config for Zabbix

Update the php config to optimize for Zabbix installation.

Open the php ini file

1
sudo vim /etc/php/8.1/cli/php.ini

Then modify these settings to the values shown. Update the timezone to fit yours.

1
2
3
4
memory_limit = 2G
max_execution_time = 360
date.timezone = Africa/Nairobi
cgi.fix_pathinfo=0

Next let us edit the php-fpm settings.

1
sudo vim /etc/php/8.1/fpm/pool.d/www.conf

Then update these values

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
listen = /run/php/php8.1-fpm.sock

user = www-data
group = www-data

listen.allowed_clients = 0.0.0.0
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm = dynamic

Save the changes and exit the file.

# Start and enable php-fpm service

The php-fpm service is started by default. Confirm by checking the status:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
$ sudo systemctl status php8.1-fpm
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-10-20 18:50:53 UTC; 9min ago
       Docs: man:php-fpm8.1(8)
   Main PID: 114987 (php-fpm8.1)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
      Tasks: 3 (limit: 4392)
     Memory: 8.2M
        CPU: 129ms
     CGroup: /system.slice/php8.1-fpm.service
             ├─114987 "php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             ├─114988 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             └─114989 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

Oct 20 18:50:53 unstable-ubuntusrv systemd[1]: Starting The PHP 8.1 FastCGI Process Manager...
Oct 20 18:50:53 unstable-ubuntusrv systemd[1]: Started The PHP 8.1 FastCGI Process Manager.

Enable the service to start on boot

1
sudo systemctl enable php8.1-fpm

At this point, we have successfully installed the LAMP stack. We can now install Zabbix

# Install Zabbix

Zabbix is not available in the default Ubuntu repositories but it provides a repository.

First, download and Install the zabbix repository

1
2
curl -LO https://repo.zabbix.com/zabbix/6.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.2-2%2Bubuntu22.04_all.deb
sudo dpkg -i zabbix-release_6.2-2%2Bubuntu22.04_all.deb

Once the repository is installed, install the Zabbix server, Zabbix agent, and the associated Zabbix packages.

1
sudo apt update && sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent

Next, import the database schema:

1
sudo zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -u zabbix_user -p zabbix

When prompted for a password, provide the Zabbix user’s password.

Edit Zabbix configuration file and update the db credentials

1
sudo vim /etc/zabbix/zabbix_server.conf

Ensure that the*DBName, DBUser, DBPassword values reflect the values you provided for your database

1
2
3
4
DBHost=localhost
DBName=zabbix
DBUser=zabbix_user
DBPassword=S0mStrongPa$$word

Save the changes and exit the configuration file.

To apply all the changes made, restart all the services as shown

1
sudo systemctl restart zabbix-server zabbix-agent apache2

Additionally, consider enabling them on startup.

1
sudo systemctl enable zabbix-server zabbix-agent apache2

# Configure Firewall

If you have ufw firewall installed and enabled, enable web and Zabbix ports

1
2
3
4
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 10050:10051/tcp
sudo ufw enable

# Complete Zabbix Installation

To complete the installation, launch your browser, and go to this URL:

1
http://server-ip/zabbix

The first page that greets you is the Zabbix welcome page that boldly displays the version you are installing. Select the installation language and click on the Next step’ button.

Citizix - Zabbix 6 welcome page

In the next page you get a list of prerequisites, scroll all the way down and ensure all the prerequisites get the OK’ label in the last column. It’s mandatory that all the requirements are satisfied. Then hit the Next step’ button.

Citizix - Zabbix prerequisites
Citizix - Zabbix prerequisites

On the Configure DB Connection’ page. Fill out your database details. For the database port, leave it at 0. The press Next step'.

Citizix - Zabbix DB configCitizix - Zabbix DB config

Citizix – Zabbix DB config

Then specify your server’s name, confirm your time zone and feel free to select your preferred theme. Then press Next step’.

Citizix – Zabbix Server 6 Details

Citizix – Zabbix Server 6 Details

Confirm all the settings and if all looks well, press on Next step’ to finalize the installation.

Citizix - Zabbix Preinstall Summary

Citizix – Zabbix Preinstall Summary

If all the settings you provided are correct, you will get a congratulatory message notifying you of the successful setup of Zabbix’s front end. Press on the Finish’ button.

Citizix - Zabbix Install success

Citizix – Zabbix Install success

This directs you to the Zabbix login page. Log in with the following credentials:

Username: Admin
Password: zabbix

Citizix - Zabbix login page

Citizix – Zabbix login page

Then click on Sign in’ to access the Zabbix dashboard. You can change the password later for added security, so don’t worry about that.

Finally, you will get access to Zabbix’s dashboard

Citizix – Zabbix 6 dashboard

Citizix – Zabbix 6 dashboard

That is it! We have successfully installed the Zabbix monitoring tool on Ubuntu 22.04.

Last updated on Mar 20, 2024 17:19 +0300
comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy