Install Zabbix on Ubuntu

We will demonstrate how to install the zabbix server on a Linux machine with Ubuntu.

Downloading Zabbix

Initially, let’s access the zabbix page using the browser.

www.zabbix.com

zabbix page

Next let’s click on Downloads.

download zabbix

After that, let’s select installation by Zabbix Packages.

zabbix packages

Now we will choose the version of Zabbix and the operating system we will install. In our case, we are using ubuntu 22.

So let’s choose the latest version of zabbix and select Ubuntu.

Next let’s select Ubuntu version = 22.

Note. If we were using another Linux distribution, we could choose the installation type at that time.

Also, let’s choose the zabbix componet = Server, Frontend, Agent. That way we can install the zabbix server and also a local zabbix agent.

After that, we will select the database that we will use. In this case, let’s use MySQL.

Now, let’s select the WEB server that will host the zabbix frontend. In this tutorial, we will choose Apache.

zabbix using MySQL

Installing Zabbix Server

Now, let’s scroll down the page and let’s start the zabbix installation part. For this, we will use the commands described on the website.

Install Zabbix repository

First we will choose the location where we will download the Zabbix repository on our computer.

In this case, we will choose the Downloads folder. However, the user can choose another folder.

cd Downloads

Next let’s download zabbix with the command below:

wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
using wget to download zabbix repository

Note. Remember that when you are following this tutorial, the version of Zabbix may have changed; if that happens, you can replace the command above with the command described on the Zabbix website.

Now we are going to install the “.deb” file that we downloaded.

For this, we will use the command below:

sudo dpkg -i zabbix-release*
Using dpkg on zabbix package

Next let’s do the update

sudo apt update
Updating our repository

Now we will install zabbix and the necessary components for the Zabbix server to work.

For that, let’s use the command below.

sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent
Installing zabbix , apache , zabbix agent ….

To confirm the installation, type “Y” and then press ENTER.

confirm installation

The figure below shows the completed installation.

Installation complete

Creating the database for zabbix

To create the database for zabbix we will use the command below.

sudo mysql -uroot -p

How to resolve Can’t connect to local MySQL server through socket error

If an error like the one in the figure below appears.

Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock

error : Can’t connect to local MySQL server through socket

This means you don’t have mysql-server installed yet.

So let’s install mysql-server using the command below.

sudo apt-get install mysql-server
Installing mysql server

Note. We assume the machine we are installing Zabbix on did not previously have a MySQL database.

Creating the database

Next, we need to enter a password for the database. In this example, let’s use password = 123456

Using MySQL

Now let’s type the command below.

create database zabbix character set utf8mb4 collate utf8mb4_bin;
Creating database zabbix

Next, let’s type the command below.

create user zabbix@localhost identified by ‘password‘;

Instead of ‘password’ let’s use our password which is 123456. So in our case the command will be :

create user zabbix@localhost identified by '123456';
Creating zabbix user

Now, let’s grant privileges to the database with the command below.

grant all privileges on zabbix.* to zabbix@localhost;
granting privileges

Next let’s use the command below.

set global log_bin_trust_function_creators = 1;
setting global log bin trust function creators

Finally let’s finish with the command below.

quit;
exiting database

Importing Zabbix server and initial schema

To import the initial schema and data, let’s use the command below.

Remember that after the command, we will be asked for the password we used. Therefore, we will use the same password that we used earlier. Therefore, our password is 123456.

sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix 
importing zabbix initial schema

Note. After entering your password, it is common to take a long time to process. So take it easy.

Disabling the log_bin_trust_function_creators option

The zabbix website recommends that we disable the log_bin_trust_function_creators option. So let’s disable it using the commands below.

sudo mysql -uroot -p

Then we will use the same password that we created earlier, and ours is 123456.

entering mysql again

Next, let’s use the command below.

set global log_bin_trust_function_creators = 0;
setting global log bin trust function creators

Now, let’s finish with the command below.

quit;
quiting database

Configuring Zabbix server access

To do this, let’s enter the /etc/zabbix/zabbix_server.conf file.

Let’s use the command below.

sudo nano /etc/zabbix/zabbix_server.conf

Next let’s look for the DBPassword= line and let’s include our password 123456.

DBPassword=123456
Configuring DB Password

After that, let’s save the changes and exit the nano editor.

Start Zabbix server and agent

To start the zabbix server, the zabbix agent and the apache server let’s use the command below.

sudo systemctl restart zabbix-server zabbix-agent apache2

Now, let’s configure so that the zabbix server, zabbix agent and apache server are started together with the operating system.

sudo systemctl enable zabbix-server zabbix-agent apache2

Starting zabbix in browser

Let’s open a browser and type the link below.

http://localhost/zabbix 

In this case we are accessing zabbix using the loopback address = localhost which can also be replaced by “127.0.0.1”.

To access the Zabbix server from another machine, you must enter the Zabbix server machine IP in the client machine’s browser, as in the example below.

http://zabbix_serverIP/zabbix
first zabbix access

After choosing the language, click on “Next step”.

Next, we will check the prerequisites as shown in the figure below. Then let’s click on “Next step.

zabbix checking pre-requisites

After checking the prerequisites, let’s now configure database access.

For this, we will include the password that we defined earlier.

In this case, our password was 123456. Then we will click on “Next step.

configuring db connection

Now let’s define the Zabbix server name and the time zone.

In our example, we will use the name “my_zabbix” and the time zone of Sao Paulo. Then we will click on “Next step.

configuring zabbix server name and time zone

Next is a pre-installation summary. In this case, we will just confirm and click on “Next step.

zabbix pre-installation summary

In the figure below, we can see that we managed to install the zabbix server fronted.

So let’s click Finish.

finishing zabbix installation

Starting the frontend of the zabbix server

Now, let’s start typing the default user which in this case is “Admin” and the password which in this case is “zabbix”.

No quotes.

login zabbix using user Admin and password zabbix

Finally we have zabbix installed and we will see a page like the one below.

zabbix global view

See also:

How to install Zabbix on Raspberry Pi

Juliana Mascarenhas

Data Scientist and Master in Computer Modeling by LNCC.
Computer Engineer