This article is for those looking for a detailed and clear guide on how to install Zabbix on Ubuntu Server.

Zabbix is an open-source, enterprise-class distributed monitoring solution.

In this guide, we will consider the case when you already have a server with the Ubuntu Server 20.04 LTS operating system installed on it.

You can read more about how to install Ubuntu Server 20.04 LTS in my guide “Install Ubuntu Server 20.04 LTS”.

In addition, OpenSSH must be installed on the server, and port 22 must be open in order to be able to connect to the server using the SSH protocol.

To install OpenSSH on a server, you can use the command:

sudo apt install openssh-server

If you plan to connect to the server using the Windows operating system, you can use PuTTY, a free client for various remote access protocols, including SSH, Telnet, rlogin.

This guide describes how to connect to a server using the iTerm2 terminal emulator installed on the macOS operating system.

Please note that you will need to open the following TCP ports to access your server:

  • 80 - to get a free cryptographic certificate through Let’s Encrypt CA.
  • 443 - to access the Zabbix frontend.
  • 10050 - for Zabbix Agent to work.
  • 10051 - for Zabbix Trapper to work.

We connect to the server on which you plan to install Zabbix.

To obtain and subsequently renew a free SSL certificate, we will use the Let’s Encrypt certification authority, as well as the Certbot software client, which is designed to make it as easy as possible to obtain and renew a certificate through the Let’s Encrypt certification authority.

Now you need to download and install the Zabbix repository configuration package.

Download the Zabbix repository configuration package using the command:

wget https://repo.zabbix.com/zabbix/5.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.2-1+ubuntu20.04_all.deb

Install Zabbix on Ubuntu Server

Install the Zabbix repository configuration package using the command:

sudo dpkg -i zabbix-release_5.2-1+ubuntu20.04_all.deb

Install Zabbix on Ubuntu Server

Update the local package index to the latest changes in the repositories using the command:

sudo apt update

Install Zabbix on Ubuntu Server

Now let’s install the packages required for Multicraft to work using the command:

sudo apt install -y apache2 apt-transport-https certbot python3-certbot-apache mysql-server zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent

Please note that in this tutorial, MySQL will be used as a database management system, and Apache will be used as a webserver.

Install Zabbix on Ubuntu Server

We enable the Apache webserver module called “rewrite” using the command:

sudo a2enmod rewrite

Note that the “rewrite” module is one of the most commonly used modules in the Apache webserver and provides a flexible and powerful way to manipulate URLs.

Install Zabbix on Ubuntu Server

Now you need to create a virtual host file (called a block in Nginx), with which Zabbix will work in the future.

Let’s create a virtual host file using a text editor using the command:

sudo vim /etc/apache2/sites-available/zabbix.heyvaldemar.net.conf

In this tutorial, the zabbix.heyvaldemar.net subdomain will be used to access the Zabbix control panel from the Internet. You will need to specify your domain or subdomain by which your Zabbix will be accessible from the Internet.

Install Zabbix on Ubuntu Server

Click on the “i” button to go into edit mode, then insert the following configuration for the webserver to work.

In this tutorial, the zabbix.heyvaldemar.net subdomain will be used to access Zabbix from the Internet. You will need to specify your domain or subdomain by which your Zabbix will be accessible from the Internet.

Install Zabbix on Ubuntu Server

Now press the “Esc” button to exit edit mode, then type “:x” and press the “Enter” button to save your changes and exit the editor.

Install Zabbix on Ubuntu Server

We activate the created virtual host using the command:

sudo a2ensite zabbix.heyvaldemar.net.conf

In this tutorial, the zabbix.heyvaldemar.net subdomain will be used to access the Zabbix control panel from the Internet. You will need to specify your domain or subdomain by which your Zabbix will be accessible from the Internet.

Install Zabbix on Ubuntu Server

Deactivate the default virtual host using the command:

sudo a2dissite 000-default.conf

Install Zabbix on Ubuntu Server

Verify that there are no errors in the syntax of the new Apache config file using the command:

sudo apache2ctl configtest

Install Zabbix on Ubuntu Server

Restart Apache to apply the changes made using the command:

sudo systemctl restart apache2

Install Zabbix on Ubuntu Server

Let’s check that Apache has started successfully using the command:

sudo systemctl status apache2

Install Zabbix on Ubuntu Server

Now, in order to increase the security level of the webserver, you need to obtain a cryptographic certificate for the domain or subdomain through which your Zabbix will be accessible from the Internet.

To obtain and subsequently renew a free SSL certificate, we will use the Let’s Encrypt certification authority, as well as the Certbot software client, which is designed to make it as easy as possible to obtain and renew a certificate through the Let’s Encrypt certification authority.

In this tutorial, the zabbix.heyvaldemar.net subdomain will be used to access the Zabbix control panel from the Internet. You will need to specify your domain or subdomain by which your Zabbix will be accessible from the Internet.

Request a cryptographic certificate using the command:

sudo certbot --apache -d zabbix.heyvaldemar.net

Install Zabbix on Ubuntu Server

Next, we indicate the email address to which Let’s Encrypt will send notifications about the expiration of the cryptographic certificate and press the “Enter” button.

Install Zabbix on Ubuntu Server

The next step is to read and accept the terms of use of the services provided.

Press the button “a”, then “Enter”, if you agree with the terms of use of the services provided.

Install Zabbix on Ubuntu Server

The next step is to choose whether you would like to share the above email address with the Electronic Frontier Foundation in order to receive newsletters.

Press the “n” button, then “Enter”.

Install Zabbix on Ubuntu Server

At the next stage, you need to choose: do you want the parameters to be automatically added to the Apache configuration file for automatically redirecting HTTP traffic to HTTPS.

Press the button “2”, then “Enter”.

Install Zabbix on Ubuntu Server

Please note that cryptographic certificates obtained through Let’s Encrypt CA are valid for ninety days. Certbot automatically adds a script to renew the certificate to the task scheduler and the script runs twice a day, automatically renewing any cryptographic certificate that expires within thirty days.

You can check the functionality of the cryptographic certificate renewal process using the command:

sudo certbot renew --dry-run

Install Zabbix on Ubuntu Server

Now let’s configure MySQL for further work with Zabbix.

First, you need to run the “mysql_secure_installation” script, which is designed to provide a basic level of MySQL security.

Run the script using the command:

sudo mysql_secure_installation

Install Zabbix on Ubuntu Server

Next, you need to answer a few questions to ensure a basic level of MySQL security.

The first question is whether you want to use the password strength plugin, which will need to be set later for the “root” user who has administrator rights in MySQL.

Press the “y” button, then “Enter”.

Install Zabbix on Ubuntu Server

The next step is to select the level of password complexity checking, which will need to be set later for the “root” user who has administrator rights in MySQL.

In this tutorial, we will look at the highest level of password strength checking for the “root” user.

Press the button “2”, then “Enter”.

Install Zabbix on Ubuntu Server

The next step is to provide a strong password for the “root” user who has administrator rights in MySQL.

Specify a strong password for the “root” user and press the “Enter” button.

Install Zabbix on Ubuntu Server

Next, specify the password for the “root” user again and press the “Enter” button.

Install Zabbix on Ubuntu Server

The next question is if you would like to proceed to the next step in setting up a basic MySQL security level with the obtained password strength value.

Please note that if the password you specified will have a value of “Estimated strength of the password” less than 100, it means that the password you specified earlier for the “root” user is not strong enough, and you need to specify a stronger password.

In this tutorial, the “Estimated strength of the password” value is 100, which indicates that the previously specified password is strong enough.

Press the “y” button, then “Enter”.

Install Zabbix on Ubuntu Server

The next question is if you want to delete anonymous users.

Press the “y” button, then “Enter”.

Install Zabbix on Ubuntu Server

The next question is if you want to disable remote MySQL connectivity for the “root” user.

Press the “y” button, then “Enter”.

Install Zabbix on Ubuntu Server

The next question is if you want to drop the test databases.

Press the “y” button, then “Enter”.

Install Zabbix on Ubuntu Server

Now you need to apply the changes you made.

Press the “y” button, then “Enter”.

Install Zabbix on Ubuntu Server

Now you need to create a database that Zabbix will use in the future, as well as a user with the necessary rights to this database.

We connect to the MySQL management console using the command:

sudo mysql -u root -p

Install Zabbix on Ubuntu Server

Specify the password for the “root” account, set it earlier, and press the “Enter” button.

Install Zabbix on Ubuntu Server

This tutorial will use “zabbixdb” as the database name for Zabbix.

Let’s create a database that Zabbix will use in the future using the command:

CREATE DATABASE zabbixdb CHARACTER SET utf8 COLLATE utf8_bin;

Install Zabbix on Ubuntu Server

In this tutorial, “zabbixdbuser” with the password “c@e3]Y88n)63}^4w^43]” will be used as the username with database rights to run Zabbix.

Create a user and assign a password to it using the command:

CREATE USER 'zabbixdbuser'@'localhost' IDENTIFIED BY 'c@e3]Y88n)63}^4w^43]';

Install Zabbix on Ubuntu Server

We grant the new user rights to the previously created database using the command:

GRANT ALL ON zabbixdb.* TO 'zabbixdbuser'@'localhost';

Install Zabbix on Ubuntu Server

Apply the changes made using the command:

FLUSH PRIVILEGES;

Install Zabbix on Ubuntu Server

Disconnect from the MySQL Management Console using the command:

quit

Install Zabbix on Ubuntu Server

Now you need to configure the schema and import the data into the previously created database for Zabbix to work.

This tutorial uses “zabbixdb” as the database name for the Zabbix operation.

In this tutorial, “zabbixdbuser” is used as the username with database rights to run Zabbix.

Let’s configure the schema and import the data into the previously created database using the command:

zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -u zabbixdbuser -p zabbixdb

Install Zabbix on Ubuntu Server

Specify the password for the “zabbixdbuser” account specified earlier and press the “Enter” button.

Install Zabbix on Ubuntu Server

Now you need to make changes to the Zabbix configuration file by opening it in a text editor using the command:

sudo vim /etc/zabbix/zabbix_server.conf

Install Zabbix on Ubuntu Server

In this tutorial, the database for Zabbix to work is on the same server as Zabbix.

Press the “i” button to switch to edit mode, find the “DBHost” parameter and uncomment it by removing the “#” symbol. Then we specify the value “localhost” for the parameter.

This tutorial uses “zabbixdb” as the database name for Zabbix operation.

Find the “DBName” parameter and specify the value “zabbixdb” for the parameter.

In this tutorial, “zabbixdbuser” is used as the username with database rights to run Zabbix.

Find the “DBUser” parameter and specify the value “zabbixdbuser” for the parameter.

Find the “DBPassword” parameter and uncomment it by removing the “#” symbol. Then, as the value for the parameter, we specify the password assigned to the “zabbixdbuser” user.

Install Zabbix on Ubuntu Server

Now press the “Esc” button to exit edit mode, then type “:x” and press the “Enter” button to save your changes and exit the editor.

Install Zabbix on Ubuntu Server

Now you need to make changes to the Apache configuration file by opening it in a text editor using the command:

sudo vim /etc/zabbix/apache.conf

Install Zabbix on Ubuntu Server

Next, find the “php_value date.timezone Europe/Riga” parameter in the “IfModule mod_php7.c” section and uncomment it by removing the “#” symbol. Then we indicate instead of “Europe/Riga”, the time zone in which your Zabbix server is located.

A list of supported time zones can be found here.

Install Zabbix on Ubuntu Server

Now press the “Esc” button to exit edit mode, then type “:x” and press the “Enter” button to save your changes and exit the editor.

Install Zabbix on Ubuntu Server

Restart Zabbix, Zabbix Agent, and Apache to apply the changes, using the command:

sudo systemctl restart zabbix-server zabbix-agent apache2

Install Zabbix on Ubuntu Server

Check that Zabbix has started successfully using the command:

sudo systemctl status zabbix-server

Install Zabbix on Ubuntu Server

Check that Zabbix Agent has started successfully using the command:

sudo systemctl status zabbix-agent

Install Zabbix on Ubuntu Server

Let’s check that Apache has started successfully using the command:

sudo systemctl status apache2

Install Zabbix on Ubuntu Server

Enable autorun of Zabbix, Zabbix Agent, and Apache when starting the operating system using the command:

sudo systemctl enable zabbix-server zabbix-agent apache2

Install Zabbix on Ubuntu Server

To continue the Zabbix installation process, you need to go from the workstation to the link https://zabbix.heyvaldemar.net/setup.php, where zabbix.heyvaldemar.net is the name of my server. Accordingly, you need to specify the name or IP address of your Zabbix server.

Click on the “Next step” button.

Install Zabbix on Ubuntu Server

Next, the installer will check that all the requirements for the correct installation of Zabbix are met.

Click on the “Next step” button.

Install Zabbix on Ubuntu Server

Now you need to specify the system for managing the databases and the previously created database that will be used to run Zabbix.

In the “Database type” field, select “MySQL”.

In this tutorial, the database for Zabbix to work is on the same server as Zabbix.

In the “Database host” field, specify “localhost”.

In the “Database port” field, specify the value “0” to use the default port for connecting the database.

This tutorial uses “zabbixdb” as the database name for the Zabbix operation.

In the “Database name” field, specify “zabbixdb”.

In this tutorial, “zabbixdbuser” is used as the username with database rights to run Zabbix.

In the “User” field, specify “zabbixdbuser”.

In the “Password” field, specify the password assigned to the “zabbixdbuser” user.

Click on the “Next step” button.

Install Zabbix on Ubuntu Server

Next, you need to specify information about your Zabbix server.

In the “Host” field, specify “localhost”.

In the “Port” field, enter “10051”.

Click on the “Next step” button.

Install Zabbix on Ubuntu Server

We check that the time zone is set correctly and click on the “Next step” button.

Install Zabbix on Ubuntu Server

Then click on the “Next step” button to save the changes.

Install Zabbix on Ubuntu Server

Everything is ready to use Zabbix.

Click on the “Finish” button.

Install Zabbix on Ubuntu Server

Now you can log into the Zabbix dashboard as a Zabbix administrator.

Login for Zabbix administrator account by default: Admin

The default password for Zabbix administrator account: zabbix

Specify the username and password of an account with Zabbix administrator rights and click on the “Sign in” button.

Install Zabbix on Ubuntu Server

Welcome to the Zabbix dashboard.

Install Zabbix on Ubuntu Server

Vladimir Mikhalev
hey, I’m Vladimir Mikhalev, but my friends call me Valdemar. I have a lot of experience in the design and maintenance of various information systems.

Recent Posts