07.06.2023

Installing Zabbix on Ubuntu

Installing Zabbix on Ubuntu

Zabbix is a popular open-source system for monitoring IT infrastructures. It can monitor a variety of parameters, such as CPU usage, disk space, ping, host availability, network load, certain app status, run in net discovery mode, or even external thermal or pressure sensors if you need something like this, as well as create graphs and send alerts with e-mail or any service compatible for integration.
Zabbix monitoring can work with an agent program as well as with existing system or device resources (e.g., ICMP ping or SNMP, including connecting via SSH or Telnet, executing commands, and using the output as return value)
For this example let's launch Zabbix server on an Ubuntu 20.04.

Preparations

Prerequisites: ubuntu 20.04 machine with con

figured network, root acces
Default repositories have Zabbix on their list, but not the newest version. Fortunately, Zabbix maintains its own official repository.
Use root access for convenience, as most of our commands will need it, or add sudo before them, changing files in the/etc folder will also require this.

wget dpkg -i zabbix-release_6.0-4+ubuntu20.04_all.deb
dpkg -i zabbix-release_6.0-4+ubuntu20.04_all.deb

apps necessary: server itself, database, php engine and sql scripts.

apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts

Configuring Mysql

Server requires a database to work with, so let's start one.

apt install mysql-server
systemctl start mysql.service

Login as root, otherwise it won't let us do all the things required.

mysql -uroot -p

When we first log in, we'll be asked to come up with a password.
Make the base, and a user to use it (leave the quotes if you change password)

create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'password';
grant zabbix@localhost all privileges on zabbix.*;

That variable let's you insert a template database.

set global log_bin_trust_function_creators = 1;
exit;

Get template configuration: zcat gives us the content of gzip file by the url, and '|' (pipe), takes the result of previous comand as an input for the next one, effectivly putting file's contents in database as a command.

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -u zabbix -p zabbix

Log back into Mysql and Disable binary logging by changing it back to zero.
Remove comment ("#" sign) from the "DBPassword=" and add user password from earlier in/etc/zabbix/zabbix_server.conf

PHP server

Open /etc/zabbix/nginx.conf. Enable "listen' and 'server_name' same way as a previous one. "listen 8080" defines the port where our web interface will be available, don't touch it unless you have something else running on php, and in "server_name" put server's address instead of "example.com".

Let's check available locales with.

locale -a

if en_US.utf8 is here - then everything's fine.
If not - edit /etc/locale.gen file, uncomment en_US.utf8 line, or any language you need and then run.

locale-gen

And check again.
Almost ready, let's get server going and launch on startup.

systemctl restart zabbix-server php7.4-fpm
systemctl enable zabbix-server php7.4-fpm

Go to http://server_ip:8080 and have a look at our future monitoring system.
All is fine.

Let us go ahead and check if everything's working.

In DataBase type - choose Mysql, type zabbix as base and username, password same as earlier.

Any name you like.

Once again, check if everything is ok.

Server is ready. Go further and enter credentials.
Admin zabbix
Enter your own afterwards at Administration > users > Admin > change password

Conclusion

Today we have taken the first step towards setting up a monitoring system by deploying Zabbix server on Ubuntu 20.04.