Install and Configure Zabbix on Ubuntu 20.04

In this article, we want to teach you How To Install and Configure Zabbix on Ubuntu 20.04.

Zabbix is an open-source monitoring software tool for diverse IT components, including networks, servers, virtual machines (VMs), and cloud services.

It provides monitoring metrics, such as network utilization, CPU load, and disk space consumption.

The software monitors operations on Linux, Hewlett Packard Unix (HP-UX), Mac OS X, Solaris, and other operating systems (OSes); however, Windows monitoring is only possible through agents.

How To Install and Configure Zabbix on Ubuntu 20.04

Before you start to install Zabbix on Ubuntu 20.04, you need some requirements first.

Requirements

You need to log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our article the Initial Server Setup with Ubuntu 20.04.

Also, you need to have the LAMP stack installed on your server. For this, you can check our article How To Install LAMP Stack on Ubuntu 20.04.

When you are done with these requirements you can follow the steps below to install Zabbix on Ubuntu 20.04.

Configure PHP and Create a Zabbix Database on Ubuntu 20.04

We assumed that you have installed the LAMP stack on your server. First, you need to install some PHP extensions for Zabbix on Ubuntu 20.04 with the following command:

sudo apt install php-mbstring php-gd php-xml php-bcmath php-ldap php-mysql

Then, you need to edit the oho.ini file and make some configuration changes. Open the file with your favorite text editor, here we use vi:

sudo vi /etc/php/7.4/apache2/php.ini

At the file, find the lines below and change the values as shown below:

memory_limit 256M
upload_max_filesize 16M
post_max_size 16M
max_execution_time 300
max_input_time 300

Also, find the lines below and uncomment them by removing the “:” from the beginning of the line and setting them to:

max_input_vars 10000
date.timezone = Europe/Berlin

When you are done, save and close the file.

Then, restart Apache to apply the changes:

sudo systemctl restart apache2

Now log in to your MySQL console with the command below:

sudo mysql

Now you need to create a database for the Zabbix on Ubuntu 20.04. To do this, run the following command from your MySQL shell, here we named our database Zabbixdb you can choose your desired name.

CREATE DATABASE zabbixdb character set utf8 collate utf8_bin;

Next, create a user with the command below:

We named our user olivia, remember to choose a strong password for your user.

CREATE USER 'olivia'@'localhost' IDENTIFIED BY 'password';

Here you need to grant all the privileges to the Zabbix database:

GRANT ALL PRIVILEGES ON zabbixdb.* TO 'olivia'@'localhost' WITH GRANT OPTION;

Flush the privileges and exit from your MySQL console with the following commands:

FLUSH PRIVILEGES;
EXIT;

Set up Zabbix on Ubuntu 20.04

To install Zabbix on Ubuntu 20.04, you need to visit the Zabbix Downloads page and find the latest LTS version.

Then, use the following commands to add the Zabbix repository:

$ sudo wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb
$ dpkg -i zabbix-release_5.0-1+focal_all.deb

Update your local package index with the following command:

sudo apt update

Now use the following command to install the Zabbix server on Ubuntu 20.04:

sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent

Start and enable your Zabbix service to start on boot with the commands below:

$ sudo systemctl start zabbix-server
$ sudo systemctl enable zabbix-server

Verify that your Zabbix service is active and running on your server:

sudo systemctl status zabbix-server

In your output you will see:

Output
zabbix-server.service - Zabbix Server
Loaded: loaded (/lib/systemd/system/zabbix-server.service; enabled; vendor>
Active: active (running) since Sun 2022-01-09 09:54:12 CET; 21s ago
Main PID: 17476 (zabbix_server)
Tasks: 1 (limit: 2282)
Memory: 3.8M
CGroup: /system.slice/zabbix-server.service
└─17476 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf

Now you will need to import the Zabbix database schema.

First, switch to the Zabbix-mysql directory:

cd /usr/share/doc/zabbix-server-mysql

Then, use the following command to import the Zabbix database on Ubuntu 20.04:

zcat create.sql.gz | mysql -u olivia -p zabbixdb

Here you need to edit the Zabbix default configuration file and define the database settings. Open the file with your favorite text editor, here we use vi:

sudo vi /etc/zabbix/zabbix_server.conf

Find the lines below and uncomment them by removing the “#” from the beginning of the line and changing them to your database settings.

DBHost=localhost
DBName=zabbixdb
DBUser=olivia
DBPassword=password

When you are done, save and close the file.

Restart your Zabbix and Apache on Ubuntu 20.04 to apply the changes:

$ sudo systemctl restart zabbix-server
$ sudo systemctl restart apache2

Configure Zabbix Agent

At this point, you need to configure the Zabbix agent on your Ubuntu 20.04. Open the file with your favorite text editor, here we use vi:

sudo vi /etc/zabbix/zabbix_agentd.conf

Find the lines below and change the values as shown below:

Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix Server

When you are done, save and close the file.

Start and enable the Zabbix agent to start on boot with the commands below:

$ sudo systemctl start zabbix-agent
$ sudo systemctl enable zabbix-agent

Verify that your Zabbix agent is active and running on your Ubuntu 20.04:

sudo systemctl status zabbix-agent

In your output you will see:

Output
zabbix-agent.service - Zabbix Agent
Loaded: loaded (/lib/systemd/system/zabbix-agent.service; enabled; vendor >
Active: active (running) since Sun 2022-01-09 09:53:12 CET; 27min ago
Main PID: 16994 (zabbix_agentd)
Tasks: 6 (limit: 2282)
Memory: 4.9M
CGroup: /system.slice/zabbix-agent.service
├─16994 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─16995 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─16996 /usr/sbin/zabbix_agentd: listener #1 [waiting for connecti>
├─16997 /usr/sbin/zabbix_agentd: listener #2 [waiting for connecti>
├─16998 /usr/sbin/zabbix_agentd: listener #3 [waiting for connecti>
└─16999 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Access Zabbix Web Interface

At this point, you can access your Zabbix dashboard by typing your server’s IP address in your web browser followed by /Zabbix:

http://your-server-ip/zabbix

You will see the Zabbix welcome page just click on the next step.

In the next window, you will see the check for the prerequisites. Make sure all the required PHP extensions are installed then click on the Next step button.

Then, you will see the configure DB connection page. Set your database details and click on the next step.

Zabbix DB configuration on Ubuntu

Next, you need to set your Zabbix server details and press the next step.

Zabbix server details on Ubuntu 20.04

Now check the Zabbix pre-installation summary and click on the next step.

Zabbix pre-installation summary on Ubuntu 20.04

When your installation is completed, you will see the following page.

Zabbix frontend on Ubuntu

Click on the finish button and you will see the Zabbix login screen. Enter the Admin as a username and Zabbix as a password and click on the sign-in button.

Zabbix login screen on ubuntu 20.04

Here you will see your Zabbix dashboard.

Zabbix dashboard on Ubuntu

Conclusion

At this point, you learn to set up and configure Zabbix on Ubuntu 20.04. From now you can install Zabbix agents on more client systems and start monitoring them from the Zabbix dashboard.

Hope you enjoy it.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!