How to Install Zabbix on Ubuntu 24.04
Zabbix is a free and open-source monitoring solution for IT infrastructure. It allows you to monitor networks, servers, virtual machines, and cloud services. Zabbix offers a client/server model, you can easily install the Zabbix agent on the target server and monitor it through the Zabbix dashboard. Zabbix also supports generic monitoring protocols such as SNMP and IPMI.
In this guide, we'll show you how to install and configure Zabbix on Ubuntu 24.04 server. You'll be installing Zabbix with the PostgreSQL database server, Nginx web server, and PHP-FPM.
Prerequisites
To complete this guide, make sure you have the following:
- An Ubuntu 24.04 server
- A non-root user with admin privileges
Installing PostgreSQL server
Zabbix supports SQL databases MySQL and PostgreSQL. For this guide, you'll be using PostgreSQL as the default database for Zabbix. So now you'll be installing PostgreSQL from the official Ubuntu repository.
First, run the command below to update your Ubuntu package index.
sudo apt update
Once the repository is updated, install the PostgreSQL server on your Ubuntu machine using the command below. Enter 'Y' to confirm the installation.
sudo apt install postgresql postgresql-contrib
After the installation is finished, run the command below to check the PostgreSQL service status.
sudo systemctl is-enabled postgresql
sudo systemctl status postgresql
In the following output, you can see the PostgreSQL server is enabled and will run automatically at boot. And the status is now running.
Adding Zabbix repository
After PostgreSQL is installed, you're now ready to add the Zabbix repository to your system. In this example, you'll be setting up a repository for Zabbix 7.0 LTS.
Download the repository file for Zabbix with the following command:
wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest+ubuntu24.04_all.deb
Now run the 'dpkg' command below to install the Zabbix repository.
sudo dpkg -i zabbix-release_latest+ubuntu24.04_all.deb
Lastly, run the 'apt update' command below to refresh your Ubuntu package index again. After adding a new repository, you must refresh your package index.
sudo apt update
Installing Zabbix
Now that you've added the Zabbix repository, the next step is to install Zabbix packages to your Ubuntu server. In this section, you'll install Zabbix 7.0, PHP-FPM, Nginx web server, and some dependencies for Zabbix up and running.
To install Zabbix, run the 'apt' command below. Input 'Y' to confirm with the installation.
sudo apt install zabbix-server-pgsql zabbix-frontend-php php8.3-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
With this command, you'll install the following packages:
- Zabbix with PostgreSQL database support
- Zabbix web application or frontend
- PHP and modules including the 'pgsql' module for the PostgreSQL driver
- Nginx and configuration for Zabbix
- Zabbix SQL scripts
- Zabbix agent for monitoring the Zabbix system
Integrating Zabbix with the PostgreSQL server
Now that Zabbix is installed, the next step you'll be preparing PostgreSQL database and user, import database schema for Zabbix, and the integrate Zabbix with your PostgreSQL database and user.
Run the command below to create a new PostgreSQL user and database 'zabbix'. Enter a new password for user 'zabbix' and repeat.
sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix zabbix
After creating the database and user, run the following command to import database schema to the database 'zabbix'. When asked for a password, input your 'zabbix' password.
zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
If successful, you'll see an output such as 'IMPORT 0 1'.
Next, open Zabbix configuration '/etc/zabbix/zabbix_server.conf' using the 'nano' editor.
nano /etc/zabbix/zabbix_server.conf
Change the default configuration of 'DBName', 'DBUser', and 'DBPassword' with your PostgreSQL database details.
DBName=zabbix
DBUser=zabbix
DBPassword=password
Save the file and exit the editor when finished.
Setting up Nginx
After configuring Zabbix with PostgreSQL, you also need to configure the Nginx web server. With the 'zabbix-nginx-conf' package installed, you can modify the Nginx configuration provided by Zabbix. In this example, you'll be running Zabbix on a local domain name with the port '8080'.
Open the Nginx configuration for Zabbix '/etc/zabbix/nginx.conf' using the 'nano' editor.
sudo nano /etc/zabbix/nginx.conf
Uncomment the 'listen' and 'server_name' options like the following. In this example, Zabbix will be running on port '8080' with the local domain 'zabbix.howtoforge.local'.
listen 8080;
server_name example.com;
When done, save the file and exit the editor.
Restarting Zabbix services
At this point, you've configured Zabbix with PostgreSQL and the Nginx web server. Now you'll be restarting Zabbix services and verifying those services to ensure it is running.
Now that you've configured all zabbix components, you'll be restarting Zabbix services such as:
- zabbix-server
- zabbix-agent
- Nginx and PHP-FPM
Run the following 'systemctl' command to restart and enable those services on top.
sudo systemctl restart zabbix-server zabbix-agent nginx php8.3-fpm
sudo systemctl enable zabbix-server zabbix-agent nginx php8.3-fpm
Lastly, run the command below to check the status of each Zabbix service.
sudo systemctl status zabbix-server zabbix-agent nginx php8.3-fpm
In the following output, you can see the 'zabbix-server' is running. As well as the 'zabbix-agent' service.
Also, both Nginx and PHP-FPM services are running on the server.
Zabbix installation wizard
Now that Zabbix services are up and running, you're ready to access and configure Zabbix through the installation wizard.
First, edit the 'hosts' file on your local computer and input the Zabbix domain name and server IP address like the following:
192.168.10.60 zabbix.howtoforge.local
Now open your web browser and visit http://zabbix.howtoforge.local:8080/. If your Zabbix installation is successful, you'll see the Zabbix installation wizard.
Select your default language and click 'Next step' to continue.
Make sure that your Ubuntu server is met with Zabbix requirements and click 'Next step' again.
Select the database type as 'PostgreSQL' and input your database details, and then click 'Next step'.
Select the default time zone and theme, then click 'Next step'.
Double-check your settings and click 'Next step' to continue the installation.
If the installation is successful, you'll see the following:
Click 'Finish' to complete the installation.
You will now be redirected to the Zabbix login page. Enter the default user, 'Admin,' with the password 'Zabbix,' and then click 'Sign In.'
You'll now get the Zabbix monitoring dashboard like the following:
Conclusion
Congratulations! You've completed the installation of the Zabbix monitoring solution on the Ubuntu 24.04 server. You've Zabbix up and running with the PostgreSQL server, Nginx web server, and PHP-FPM. For the next step, you may want to add a target monitoring server through the Zabbix agent and set up notifications when an error occurs.