This article is written for those who were searching for a detailed and simple for the understanding guide on how to install Zabbix on Ubuntu Server.

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.

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

You can read more about how to install Ubuntu Server 18.04 LTS in my guide «Installing Ubuntu Server 18.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 the server, you can use the command:

sudo apt-get install openssh-server

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

This guide covers connecting 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 receive a free cryptographic certificate through the Let’s Encrypt certificate authority.
  • 443 – to access the Zabbix control panel.
  • 10050 – for Zabbix Agent.
  • 10051 – for Zabbix Trapper.

Connect to the server on which it is planned to install Zabbix.

This guide discusses how to obtain a free cryptographic certificate through the Let’s Encrypt Certificate Authority. To receive and further update the free SSL certificate, we will use the Certbot software client, which is designed to simplify the receipt and renewal of the certificate through the Let’s Encrypt certificate authority.

Add the Certbot repository using the command:

sudo add-apt-repository ppa:certbot/certbot

Press the “Enter” button to confirm the addition of a new repository.

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/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3+bionic_all.deb

Install the Zabbix repository configuration package using the command:

sudo dpkg -i zabbix-release_4.0-3+bionic_all.deb

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

sudo apt update

Now install the packages necessary for Zabbix and Zabbix Agent to work using the command:

sudo apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-agent certbot python-certbot-apache

Please note that in this guide, MySQL will be used as the database management system, and Apache will be used as the web server.

Enable the Apache web server module called “rewrite” with the command:

sudo a2enmod rewrite

Please note that the “rewrite” module is one of the most commonly used Apache web server modules and provides a flexible and powerful way to manipulate URLs.

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

Create a virtual host file using a text editor using the command:

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

In this manual, 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 available from the Internet.

Press on the “i” button to enter the editing mode, then insert the following configuration for the webserver to work:

In this manual, 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 available from the Internet.

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

Activate the created virtual host using the command:

sudo a2ensite zabbix.heyvaldemar.net.conf

In this manual, 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 available from the Internet.

Deactivate the default virtual host using the command:

sudo a2dissite 000-default.conf

Make sure that there are no errors in the syntax of the new Apache configuration file using the command:

sudo apache2ctl configtest

Restart Apache to apply the changes using the command:

sudo systemctl restart apache2

Verify that Apache started successfully using the command:

sudo systemctl status apache2

Now, to increase the security level of the webserver, it is necessary to obtain a cryptographic certificate for the domain or subdomain, through which the Zabbix will be accessible from the Internet.

To obtain and subsequently renew a free SSL certificate, we will use the Let’s Encrypt Certificate Authority, as well as the Certbot software client, which is designed to simplify the receipt and renewal of the certificate through the Let’s Encrypt Certificate Authority.

In this manual, 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

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

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

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

At the next stage, you need to choose: do you want to share the email address indicated above with the Electronic Frontier Foundation to receive newsletters.

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

The next step is to choose: do you want the parameters to automatically redirect HTTP traffic to HTTPS be automatically added to the Apache configuration file.

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

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

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

sudo certbot renew --dry-run

Now we will configure MySQL for further work with the Zabbix.

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

Run the script using the command:

sudo mysql_secure_installation

Now it will be offered to specify the password for the user “root”, who has administrator rights in MySQL.

By default, the password for the user “root” is not set.

Press on the “Enter” button.

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

In the next step, you will be asked to set a password for the “root” user who has administrator rights in MySQL.

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

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

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

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

The next question is whether you want to remove anonymous users.

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

The next question is whether you want to disable the ability to remotely connect to MySQL for the root user.

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

The next question is whether you want to delete the test databases.

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

Now you need to apply the changes.

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

Now you need to create a database, which will be used by Zabbix, as well as a user with the necessary rights to this database.

Connect to the MySQL management console using the command:

sudo mysql -u root -p

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

In this manual, “zabbixdb” will be used as the database name for Zabbix.

Create the database that Zabbix will use in the future using the command:

CREATE DATABASE zabbixdb CHARACTER SET utf8 COLLATE utf8_bin;

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

Create the user, assign him a password, and issue the rights to the previously created database to the new user using the command:

GRANT ALL PRIVILEGES ON zabbixdb.* TO 'zabbixdbuser'@'localhost' IDENTIFIED BY 'c@e3]Y88n)63}^4w^43]';

Apply the changes using the command:

FLUSH PRIVILEGES;

Disconnect from the MySQL management console using the command:

quit

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

In this manual, “zabbixdb” is used as the database name for Zabbix.

In this manual, “zabbixdbuser” is used as the user name that has the rights to the database for Zabbix to work with.

Set up 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

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

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

In this guide, the database for running Zabbix is on the same server as Zabbix.

Press the “i” button to enter the editing mode, find the “DBHost” parameter and uncomment it by removing the “#” sign. Then specify the value “localhost” for the parameter.

In this manual, “zabbixdb” is used as the database name for Zabbix.

Find the “DBName” parameter and uncomment it by removing the “#” sign. Then specify the value “zabbixdb” for the parameter.

In this manual, “zabbixdbuser” is used as the user name that has the rights to the database for Zabbix to work.

Find the “DBUser” parameter and uncomment it by removing the “#” sign. Then specify the value “zabbixdbuser” for the parameter.

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

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

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

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

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

A list of supported time zones can be found at https://www.php.net/manual/en/timezones.php.

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

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

sudo systemctl restart zabbix-server zabbix-agent apache2

Check that Zabbix has started successfully using the command:

sudo systemctl status zabbix-server

Check that the Zabbix Agent started successfully using the command:

sudo systemctl status zabbix-agent

Verify that Apache started successfully using the command:

sudo systemctl status apache2

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

sudo systemctl enable zabbix-server zabbix-agent apache2

To continue the process of installing the Zabbix, you must go from 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 server with the Zabbix installed.

Click on the “Next step” button.

Further, the installer will verify that all the requirements for the correct installation of Zabbix are met.

Click on the “Next step” button.

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

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

In this guide, the database for running Zabbix is on the same server as Zabbix.

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

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

In this manual, “zabbixdb” is used as the database name for Zabbix.

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

In this manual, “zabbixdbuser” is used as the user name that has the rights to the database for Zabbix to work.

In the field “User” specify “zabbixdbuser”.

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

Click on the “Next step” button.

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

In the field “Host” specify “localhost”.

In the field “Port” specify “10051”.

Click on the “Next step” button.

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

Everything is ready to use Zabbix.

Click on the “Finish” button.

You can now log in to your Zabbix control panel as a Zabbix administrator account.

Default Zabbix admin account login: Admin

Password for Zabbix admin account by default: zabbix

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

Welcome to the Zabbix control panel.

Author

Hi, 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. On my website, you will find detailed and clear guides for setting up IT solutions. Dive into the ocean, full of positive and technology! For cooperation: callvaldemar@gmail.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.