How to install Zabbix Monitoring on Ubuntu 20.04 Server
Posted on September 22nd, 2022
Monitoring the applications deployed on the Ubuntu operating system is a standard industry practice for DevOps engineers and developers. With monitoring, you can sometimes detect a problem before it has negative effects. It also collects crucial data when an error occurs for the initial time.
There are many monitoring tools available; Grafana and Prometheus are a few tools that almost every company utilizes. But another tool by the name of Zabbix has caught the attention of many IT professionals because of its easy installation and pleasing user interface.
In this tutorial, we will learn how you can install one such monitoring tool – Zabbix.
What Is Zabbix And How It Works
Zabbix is a free-to-use open-source tool that monitors operating system, machines, networks, cloud services, etc. It collects all the metrics of the OS or applications and represents that data with diagrams and graphs.
This tool was released in April 2001 and is written in PHP, Java, Go, and many other languages. We can install and configure this tool on top of many operating systems. But in this tutorial, we will learn to install Zabbix on Ubuntu 20.04 LTS operating system.
Kindly follow all the steps mentioned below. I have also provided the screenshots I took while installing the Zabbix on my Ubuntu machine.
Prerequisites for Installing Zabbix on Ubuntu
We are going to install Zabbix on Ubuntu. So, a server with Ubuntu 20.04 OS is the first thing you need.
- Minimum RAM of 512 MB.
- A non-root user with sudo privilege.
Those mentioned above are the minimum requirements; a machine with 4 Gb of RAM and 100 GB of disk space is recommended choice for deploying Zabbix.
Commands For Installing Zabbix On Ubuntu Linux
The process to install Zabbix on a clean Ubuntu server is a bit lenghty. It is because we have to install LAMP stack to install Zabbix. It is because we want to access the user interface to monitor the network. We will get started by updating the apt package manager in Ubuntu.
To update the apt package manager, execute the following command on your server.
$sudo apt update
It will take a minute or two. Now we can get started with the actual installation.
1. Installing Apache2 For Zabbix Application
Installing Apache on Ubuntu is very easy. Just execute the following command to install Apache 2 on your server.
$ sudo apt install apache2 -y
The installation will complete in less than 5 minutes. You can verify the installation by accessing the public IP address of your server in your browser. Or, you can execute the following command to check the status of apache2 service.
$ sudo service apache2 status
If Apache is running, We can move on to install PHP on the server.
2. Installing PHP for Zabbix Installation
Now we will install PHP and other required PHP packages. Execute the following command to do so.
$ sudo apt install php php-mbstring php-gd php-xml php-bcmath php-ldap php-mysql -y
The command mentioned above will install the latest PHP version and its dependencies required for the Zabbix monitoring system. To verify the PHP installation, Execute the following command. It will output the current version of PHP.
$ php -v
Now, We have to update the PHP configuration to support Zabbix on the server. So, we will edit the PHP configuration file and update some directives. Execute the following command to edit the PHP configuration file.
$ sudo nano /etc/php/7.4/apache2/php.ini
Now, find the following directives and update the values as given below.
- memory_limit 256M
- upload_max_filesize 16M
- post_max_size 16M
- max_execution_time 300
- max_input_time 300
- max_input_vars 10000
Now search the scripts and update their respective values. In the nano text editor, if you want to search anything, use ctrl + W.
After making the required changes click ctrl + X and Y to save the updated changes.
$ sudo systemctl restart apache2
Explanation: After making changes in the php.ini file, we need to reload the apache server so that changes are reflected.
3. Installing MariaDB On Ubuntu
Once Apache and PHP are working, we can install and configure MariaDB on our server. MariaDB is RDBMS which is very similar and derived from MySQL. Execute the following commands to install and secure MariaDB on your server.
$ sudo apt install mariadb-server $ sudo mysql_secure_installation
MariaDB is asking a few essential configuration questions. The recommended answer to most of the above questions is Y.
Note down the password for MariaDB; you might need it later.
4. Creating A Database For the Zabbix Monitoring System
We installed MariaDB as a database management system, but we also have to create a database and a user with all the access to that database. It is very easy to do. First of all, Execute the following command to access MariaDB on your server as a root user.
$ sudo mysql -u root -p
It will ask for password, enter the password you have set while installing MariaDB. Once you are logged in, Execute the following queries to create database and a user in MariaDB.
- CREATE DATABASE yourdb character set utf8 collate utf8_bin;
- CREATE USER ‘yourusername‘@’localhost’ IDENTIFIED BY ‘yourpassword‘;
- GRANT ALL PRIVILEGES ON yourdb.* TO ‘yourusername‘@’localhost’ WITH GRANT OPTION;
- FLUSH PRIVILEGES;
Now we have the database for Zabbix. Do not forget the username and password for this user. Note them down as we will need it while installing Zabbix on the server. Now, let’s get started with actual Zabbix installation.
5. Downloading Zabbix Monitoring Packages
First, we will download the Zabbix package with the wget command. In most ubuntu machines, wget is installed by default.
If wget is not installed, then use this command –
$ sudo apt-get install wget.
$ wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb
Now execute the DEB file using the following command.
$ sudo dpkg -i zabbix-release_5.0-1+focal_all.deb
Now, we have installed the Zabbix packages with the above given command. We need to connect this Zabbix instance with the database that we created earlier. For that, we have to install additional Zabbix packages for MySQL, Apache and PHP. To do so, execute the following commands.
$ sudo apt update $ sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent zabbix-apache-conf
The installation may take a few minutes. Once the installation is complete, Open the Zabbix configuration file to set database information. Execute the following command to open Zabbix configuration file with Nano editor.
$ sudo nano /etc/zabbix/zabbix_server.conf
In nano editor, find
DBPassword directives and update the values. After editing the file, press CTRL+X and then Y to save the configuration file.
Now we have to import the database schema and initial required data in our database. To do so, execute the following commands on your server.
$ cd /usr/share/doc/zabbix-server-mysql $ zcat create.sql.gz | mysql -u yourusername -p yourdb
It will prompt you for password. Enter MySQL password we set while creating a user for Zabbix. Use the same username after
-u directive in the above given command. Once done, execute the following commands to restart Zabbix server as well as Ubuntu server.
$ sudo systemctl restart zabbix-server $ sudo systemctl restart apache2
Now, the installation is completed. To access the web console of Zabbix, we need the public IP of the ubuntu machine. You can run the command $ curl ifconfig.me to know the public IP of your ubuntu machine.
Copy this public IP and paste it into the browser with /zabbix
Example – publicip/zabbix
The Zabbix web console will now ask for details like DB name, username, password, etc.
After configuring the Zabbix, the web console will redirect you to the login page.
By default, a user is created with the following username and password. Enter this, and you will be logged in to the Zabbix monitoring web console.
Default Credentials –
- Username: Admin
- Password: zabbix
Now, you can create users and hosts and configure the entire monitoring.
How to remove Zabbix From Ubuntu 20.04?
Answer – Zabbix can be removed for ubuntu 20.04 or 16.04 by removing the Zabbix configuration files and deleting its MariaDB database.
You can try the following commands for completely removing Zabbix from your Ubuntu operating system.
$ sudo apt purge zabbix* $ sudo apt autoremove
How to restart Zabbix Server on Ubuntu?
Answer – If you have made some changes to the Zabbix configuration file and want to restart the Zabbix-server then execute the below-mentioned command
$ sudo systemctl restart zabbix-server $ sudo systemctl status zabbix-server
We have successfully installed the Zabbix Monitoring tool on top of our ubuntu operating system. With Zabbix, we can monitor hundreds of devices as it is open-source and free-to-use software for non-commercial use. We first installed the LAMP stack and then configured our Zabbix. In case of any doubt or error, please mention a comment below. We will be very happy to help you.