Zabbix is a free enterprise-class open-source monitoring tool designed to monitor server resources, networks, applications, and services. It can be used to monitor anything from the performance of one server to the activity of an entire network.
Zabbix is an ideal software to install on your Ubuntu server, whether you’re using a virtual private server (VPS) or a dedicated server.
This guide will show you how to install Zabbix on an Ubuntu 22.04 VPS or dedicated server fast and with less hassle.
How to Install Zabbix on Ubuntu Server
First, log into your server and update the packages. Next, install and configure Apache2 before installing PHP and the required modules. Next, set up MariaDB Database for your Ubuntu server, then download and install Zabbix repositories.
Install Zabbix server modules by running <apt -y install zabbix-agent zabbix-server-mysql php-mysql zabbix-frontend-php>. Configure and start the Zabbix server to start monitoring your Ubuntu 22.04 VPS or dedicated server.
Here are the key takeaways from this guide on how to install Zabbix on Ubuntu 22.04:
- You need to update all your Ubuntu server packages first before installing Zabbix
- You also need to install Apache and PHP and create a database for your Zabbix server.
- After installing Apache, you need to install PHP and the modules required to enable Apache service to utilize PHP scripts.
- You need to create a database for your Zabbix server with a username and password after installing and configuring Apache and PHP.
- If you have the Ubuntu firewall enabled, you need to permit traffic to ports: 80, 443, 10050, and 10051 after installing Zabbix.
Installing Zabbix on Ubuntu 22.04 Server: Step-by-Step Guide
Before you begin installing Zabbix server on Ubuntu 22.04 using this guide, you need to have the following dependencies installed:
- A database server (MariaDB or MySQL hosting)
- Apache web server
- LAMP stack
You can either install Zabbix from the source code or Zabbix repository. However, there are currently no Zabbix server repositories for Ubuntu 22.04, so this guide involves installing the server from the source code.
Step 1- Installing Apache
The first step is to install Apache2. But before installing Apache, you need to update your Ubuntu server packages.
Log into your Ubuntu server and run the command <sudo apt-get update> to update the packages:
After upgrading the server packages, issue the command below to install Apache2:
apt -y install apache2
Once Apache2 is installed, run the command below to open the file /etc/apache2/conf-enabled/security.conf and adjust the settings to configure the basic security.
Find the line ServerTokens OS line and change it to ServerTokens Prod.
The ServerTokens directive determines what is returned as the response for server HTTP. It has only six valid options, namely:
To change the text, navigate with the cursors to the OS word and press “I” to switch to INSERT mode.
Delete the OS characters, type “Prod, ” and then press ESC to exit INSERT mode.
Type “:x” to save and exit
If you do not want to use an editor you can change the value with one line:
sed -i 's/ServerTokens OS/ServerTokens Prod/' /etc/apache2/conf-enabled/security.conf;grep --color=auto ServerTokens /etc/apache2/conf-enabled/security.conf;
Next, run the command below to open the /etc/apache2/apache2.conf file:
For these changes to take effect, you’ll need to restart your Apache web service. Restart it by running the following command:
systemctl restart apache2
Step 2 – Installing PHP and the Required Modules
After installing Apache, you should install PHP and the modules required to enable Apache service to utilize PHP scripts.
Issue the command below to install PHP:
apt-get -y install php php-pear php-cgi php-common libapache2-mod-php php-mbstring php-net-socket php-gd php-xml-util php-mysql php-bcmath
You can execute the following command to confirm the PHP version:
This will give you an output similar to the one below:
Next, run the command below to enable conf php8.1.2-cgi:
You will be prompted to issue the command below to activate the new configuration:
systemctl reload apache2
Once you reload Apache2, open the file /etc/php/8.1/apache2/php.ini to set your correct timezone.
Find the line date. timezone and set it to your timezone. The time zones are arranged by location, and selecting one is very easy.
With vi, to find it, press “/” and type: date.timezone, then press Enter.
It will locate the first match. Press “n” to go to the next match:
Delete the “;” and go to the end of the line.
Now press “i” to enter INSERT mode and type your preferred time zone, for example, America/Toronto.
Now press ESC to exit INSERT mode, and type :x to save and exit.
To effect the changes, you need to restart Apache.
Run the command below to restart it:
systemctl restart apache2.
Step 3 – Setting Up MariaDB
After installing and configuring Apache and PHP, you need to create a database for your Zabbix server.
In this tutorial, we’ll use MariaDB as our database server.
Follow the steps below to create the Database for a Zabbix user.
Execute the command below to log in to the MariaDB command line:
mysql -u root -p
Enter your root credentials and hit ENTER to access the MariaDB shell.
Once you are on that command line, issue the command below to create the Zabbix user database: MariaDB [(none)]>
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
Then, execute the following command to grant the new user all privileges: MariaDB [(none)]>
GRANT ALL PRIVILEGES ON zabbix.* to zabbix@'localhost' IDENTIFIED BY 'password';
Next, flush the privileges: MariaDB [(none)]>
After flushing the privileges, execute the command below to exit the database command line: MariaDB [(none)]>
Step 4 – Installing the Zabbix Server.
Now that you’ve installed Apache and PHP and created a database for your server, you’re ready to install Zabbix.
To install the Zabbix server, start by executing the command below to add the Zabbix repository:
cd /tmp/; wget http://repo.zabbix.com/zabbix/6.3/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.3-1%2Bubuntu22.04_all.deb
Then install the repository in the system using the following command:
dpkg -I zabbix-release_6.3-1+ubuntu22.04_all.deb
Next, run the following command to install the Zabbix server modules:
apt -y install zabbix-agent zabbix-server-mysql php-mysql zabbix-frontend-php
You can now run the command below to start the Zabbix server:
systemctl start zabiix-server
And the following command to check the server’s status:
systemctl status zabiix-server
Step 5 – Configuring the Zabbix Server.
After successfully installing Zabbix, you need to configure the software appropriately.
First, you want to ensure that the username for the DB (Databases) username, password, and DB name are correctly configured in the /etc/zabbix/zabbix_server.conf file
Issue the following command to confirm the values:
grep -E '(DB(U|P|N))' /etc/zabbix/zabbix_server.conf
It will probably show something like this:
The lines preceded by a # are commented— delete the “#”
DBUser=Zabbix looks ok, as is DBName, but we need to configure the password of step 3.
To configure the password, launch the following command (respect the spaces):
sed -i 's/# DBPassword=/DBPassword=Hereyourpassword/' /etc/zabbix/zabbix_server.conf
We can check it worked by repeating the command below:
grep -E '(DB(U|P|N))' /etc/zabbix/zabbix_server.conf
If everything is okay, run the command below to restart the Zabbix server so the changes can be effected:
systemctl restart zabbix-server.
Now you’ll need to go back and check some PHP parameter values. To do so, issue the following command:
grep -E '(max_execution_time|max_input_time|post_max_size)' /etc/php/8.1/apache2/php.ini
The output will show something like this:
You want to increase those numbers so, edit the file /etc/php/8.1/apache2/php.ini and change the number to:
max_execution_time = 300
max_input_time = 300
post_max_size = 16M
Next, open the file /etc/zabbix/zabbix_agentd.conf and adjust the settings to enable the Zabbix agent to control the Zabbix server.
If the line is commented, delete the “#” and add zabbix.server.example.com.
Replace the part “example.com” with your valid domain name.
Now, restart the Zabbix server and enable it to start on reboot.
systemctl start zabbix-server systemctl enable zabbix-server
80, 443, 10050 and 10051 by issuing the following commands:
ufw allow http ufw allow https ufw allow proto tcp from any to any port 10050,10051
That’s it! We’ve reached the end of the step-by-step tutorial on installing Zabbix on an Ubuntu 22.04 VPS or dedicated server.
We hope you found this information helpful and that you were now able to install and deploy Zabbix on your servers successfully. If you have any questions or have problems during the installation process, don’t hesitate to contact us for help.
You can also read how to install Zabbix on CentOS7 if you have a VPS or dedicated server on CentOS 7 system.
What now after reading the tutorial? Here are some practical steps you can take from this tutorial:
- Get your VPS hosting from our list of 10 best VPS host providers in 2022
- Get a dedicated server hosting from these 10 best dedicated server hosts in 2022
- Download the latest version of Zabbix file from Zabbix Core download page and use it to install Nagios on your Ubuntu 22.04 server.
Here are more valuable resources to learn about Nagios and how to install and use it to monitor your server:
How do I install Zabbix from the source?
To install Zabbix from the source, create the Zabbix superuser account and extract Zabbix sources. Create the Zabbix database, then download and install Zabizz server modules. Configure and compile the source code for your server system.
Which is better, Nagios vs. Zabbix?
Zabbix is a better monitoring software than Nagios, considering its many features and advanced configurability. It has a higher-quality dashboard that provides more than the basic information you get from Nagios. It also has a higher level of clarity than Nagios. Read more about Zabbix vs. Nagios to help you choose better.
Is Zabbix free to use?
Yes. Zabbix is absolutely free to use since it’s released under the GPL license. You can use it for both commercial and non-commercial purposes for free, without any limitations on the number of monitored devices.