How to Install Zabbix on an Ubuntu 22.04 VPS or Dedicated Server

How to Install Zabbix on an Ubuntu 22.04 VPS or Dedicated Server

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.

 

Key Takeaways

Here are the key takeaways from this guide on how to install Zabbix on Ubuntu 22.04:

  1. You need to update all your Ubuntu server packages first before installing Zabbix
  2. You also need to install Apache and PHP and create a database for your Zabbix server.
  3. After installing Apache, you need to install PHP and the modules required to enable Apache service to utilize PHP scripts.
  4. You need to create a database for your Zabbix server with a username and password after installing and configuring Apache and PHP.
  5. 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:

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:

apt update

zabbix server install

apt upgrade

zabbix server installAfter upgrading the server packages, issue the command below to install Apache2:

apt -y install apache2

zabbix server install

zabbix server install

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.

vi /etc/apache2/conf-enabled/security.conf

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:

  • OS
  • Full
  • Minor
  • Minimal
  • Prod
  • Major

Before

zabbix server install

After

zabbix server install

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

zabbix server install

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;

zabbix server install

Next, run the command below to open the /etc/apache2/apache2.conf file:

vi etc/apache2/apache2.conf

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

zabbix server install

 

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

zabbix server install

zabbix server install

You can execute the following command to confirm the PHP version:

php -v

This will give you an output similar to the one below:

zabbix server install

Next, run the command below to enable conf php8.1.2-cgi:

a2enconf php8.1-cgi

zabbix server install

You will be prompted to issue the command below to activate the new configuration:

systemctl reload apache2

zabbix server install

Once you reload Apache2, open the file /etc/php/8.1/apache2/php.ini to set your correct timezone.

vi /etc/php/8.1/apache2/php.ini

zabbix server install

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.

zabbix server install

It will locate the first match. Press “n” to go to the next match:

zabbix server install

Delete the “;” and go to the end of the line.

zabbix server install

Now press “i” to enter INSERT mode and type your preferred time zone, for example, America/Toronto.

zabbix server install

Now press ESC to exit INSERT mode, and type :x to save and exit.

zabbix server install

To effect the changes, you need to restart Apache.

Run the command below to restart it:

systemctl restart apache2.

zabbix server install

 

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

zabbix server install

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;

zabbix server install

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';

zabbix server install

Note
Note: Remember to replace the value ‘password’ with your preferred password.

Next, flush the privileges: MariaDB [(none)]>

FLUSH PRIVILEGES;

zabbix server install

After flushing the privileges, execute the command below to exit the database command line: MariaDB [(none)]>

exit

zabbix server install

 

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

zabbix server install

Then install the repository in the system using the following command:

dpkg -I zabbix-release_6.3-1+ubuntu22.04_all.deb

zabbix server installNext, run the following command to install the Zabbix server modules:

apt -y install zabbix-agent zabbix-server-mysql php-mysql zabbix-frontend-php

zabbix server install

You can now run the command below to start the Zabbix server:

systemctl start zabiix-server

zabbix server install

And the following command to check the server’s status:

systemctl status zabiix-server

zabbix server install

 

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:

zabbix server install

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
Note
Note: Remember to replace the value ‘Hereyourpassword’ with your password from step 3.

zabbix server install

We can check it worked by repeating the command below:

grep -E '(DB(U|P|N))' /etc/zabbix/zabbix_server.conf

zabbix server install

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:zabbix server install

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.

vi /etc/zabbix/zabbix_agentd.conf

zabbix server install

If the line is commented, delete the “#” and add zabbix.server.example.com.

Replace the part “example.com” with your valid domain name.

zabbix server install

Now, restart the Zabbix server and enable it to start on reboot.

systemctl start zabbix-server

systemctl enable zabbix-server

zabbix server install

Note
Note: If you have the Ubuntu firewall enabled, you will need to permit traffic to ports:

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

 

Conclusion

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.

 

Next Steps

What now after reading the tutorial? Here are some practical steps you can take from this tutorial:

 

Further Reading

Here are more valuable resources to learn about Nagios and how to install and use it to monitor your server:

  1. https://techblog.geekyants.com/zabbix-an-introduction-to-the-server-monitoring-tool
  2. https://www.devopsschool.com/blog/what-is-zabbix-and-how-it-works-an-overview-and-its-use-cases/
  3. https://technologyrss.com/how-to-install-zabbix-server-6-2-on-ubuntu-22-04/
  4. https://kifarunix.com/install-zabbix-server-on-ubuntu/
  5. https://www.liquidweb.com/kb/zabbix-ubuntu-20-04/

 

FAQs

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.

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How To Set up a VSFTPD Server on an Ubuntu 16.04 VPS or Dedicated Server

Brief Description FTP data is usually insecure since information (usernames, pa
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to use phpMyAdmin to develop a website (without MySQL experience)

Brief description A web developer who is not well versed into coding websites f
2 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install MySQL on a Windows Web Server Running Apache

This tutorial will show you how to install the MySQL database on a Windows serve
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top