In this tutorial, we will install and configure Zabbix on Ubuntu. But before proceeding with the tutorial, let’s se what Zabbix is.
What is Zabbix?
Zabbix is a free, open-source enterprise grade tool that is very crucial for server administrators. It offers robust features to monitors server performance, network, server health, application and many other parameters in real-time that can help administrators to keep an eye on each and every problem. You can configure Zabbix to send an email for any problem that is arising on the server. Not only that, but you can use Zabbix to generate visualized data for monitoring purposes.
Right after the configuration, you can access Zabbix directly from the browser in the same way as any website. Zabbix can be used as an important tool to monitor IT infrastructure.
In this Tutorial, we will see
Benefits to use Zabbix
- It’s Free and Open Source
- Monitors each and every problem in real time
- Highly scalable to monitor many devices
- It’s web based, so no need to approach system administrator
- Supports various platforms like Linux, Windows, Unix and network devices
- Supports API integration to automate report generation and others
- It supports alert mechanism which means you get alert as per your threshold limit
- Adds security by enabling and monitoring real time system activity
- Very easy implementation
Install and Configure Zabbix on Ubuntu
Installation and configuration of Zabbix is very easy and you can follow the steps below to configure it. We will use Nginx as our web server as it’s fast, performance oriented and use less resources. We will use PostgreSQL to the data generated by the server.
Prerequisites
- A Ubuntu server with initial server configuration done
- A user with sudo privileges
Step 1 – Update the System Repositories and Packages
The first step before configuring Zabbix is to update the repositories and packages. Let’s do that.
# sudo apt update
# sudo apt upgrade -y
# sudo apt --reinstall install dpkg -y
Step 2 – Install Nginx
Next, let’s install our web server.
# sudo apt install nginx -t
As the installation completes, we will enable the service
# sudo systemctl start nginx
# sudo systemctl enable nginx
Step 3 – Install PostgreSQL
To save the data generated by the server and analyze it later, we need to save the data somewhere. For that we will use PostgreSQL. Let’s install PostgreSQL.
# sudo apt install postgresql postgresql-contrib -y
Next, let’s create a database and a user
CREATE USER zabbix WITH PASSWORD 'password';
CREATE DATABASE zabbix OWNER zabbix;
\q
Note: Make sure to change database name "zabbix", database user "zabbix" and password "password" as per your need.
Step 4 – Install Zabbix Server, Agent and Frontend
Next step is to install Zabbix server, frontend and agent which will allow our web based app to work. Let’s first install Zabbix configuration package
# sudo curl -O https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-6+ubuntu24.04_all.deb
# sudo dpkg -i zabbix-release_6.0-6+ubuntu24.04_all.deb
# sudo dpkg -i zabbix-release_6.0-6+ubuntu24.04_all.deb
# sudo apt update
Next step is to install Zabbix server, agent and frontend
# sudo apt install zabbix-server-pgsql zabbix-frontend-php php8.3-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent -y
Step 5 – Configure Database for Zabbix
Next step is to configure Zabbix to use our database that we have created in Step 3.
zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
Now let’s configure Zabbix server to use our database
# sudo nano /etc/zabbix/zabbix_server.conf
Update the given below parameters in the file as per the credentials used in Step 3
DBName=zabbix
DBUser=zabbix
DBPassword=password
Note: Update the above parameters as per the details you have entered in step 3
Save and close the file.
Step 6 – Setup PHP for Zabbix Frontend
Open the file /etc/zabbix/nginx.conf and update the listen and server_name directives as shown below
server {
listen 80;
server_name zabbix.your_domain.com;
...
}
Note: Update "zabbix.your_domain.com" to your real domain name.
save and close the file
Let’s start the server and enable the service
# sudo systemctl start zabbix-server zabbix-agent nginx php8.3-fpm
# sudo systemctl enable zabbix-server zabbix-agent nginx php8.3-fpm
Step 7 – Configure Let’s Encrypt
We will use certbot as the tool to configure Let’s Encrypt SSL certificate. Let’s first install certbot
# sudo apt install certbot python3-certbot-nginx -y
Generate SSL certificate for your domain
# sudo certbot --nginx -d zabbix.your_domain.com
Note:- Make sure to change "zabbix.your_domain.com" to your real domain name.
Follow the prompts to generate the SSL certificate
Step 8 – Configuring the Firewall
Next step is to install and configure the firewall so that we can access our portal. So first let’s install UFW
# sudo apt install ufw -y
Let’s configure UFW rules
# sudo ufw allow http
# sudo ufw allow https
# sudo ufw reload
Step 10 – Setting up locale
Setting up locale in your server is very important, otherwise your setup won’t work.
# sudo apt-get install locales
# sudo locale-gen en_US.UTF-8
# sudo update-locale LANG=en_US.UTF-8
Now open “your_domain” on any browser and follow the gui based setup. Make sure to use the details as per our Step 3 while setting things up.
Conclusion
With this we have configured Zabbix on our Ubuntu server with PostgreSQL. Keep the server working for a couple of days so that some data is generated to analyze.