Zabbix is an open-source web-based monitoring tool for monitoring a diverse range of IT components. This includes network devices such as servers, virtual machines, and applications. It provides a plethora of monitoring metrics such as network utilization, CPU load, and disk utilization. This makes troubleshooting easier when the system is behaving abnormally. You can visualize the performance metrics in the form of graphs, screens, maps, and overviews.
In this guide, we show you how to install Zabbix server 5.0 on Ubuntu 20.04 LTS.
Before getting started, ensure you have a running Ubuntu 20.04 instance with sudo privileges. Also, ensure you are connected to a stable internet connection.
Step 1: Install and Setup Apache
In this step, we install the Apache webserver. First, update all Ubuntu repository lists and install Apache packages by running the command below:
$ sudo apt update
Now Install apache using the following command:
$ sudo apt install apache2
Apache service will start by default after installation. Incase not started run the following command to start apache2.
$ sudo systemctl start apache2
To enable apache2 on boot, type:
$ sudo systemctl enable apache2
Step 2: Install PHP and associated modules
The front-end of Zabbix is written in PHP and because of that we need to install PHP. Already, Ubuntu provides in its repositories which by default is PHP 7.4. This is what we are going to use for this guide.
To Install PHP packages use the following apt command:
$ sudo apt install php php-mbstring php-gd php-xml php-bcmath php-ldap php-mysql
You can verify the version of PHP installed using the following command:
$ php -v
Once the installation is complete, head over to the PHP configuration directory and edit the /etc/php/7.4/apache2/php.ini file. Modify the parameters as shown and be sure to set the right time zone according to your locale.
$ sudo vim /etc/php/7.4/apache2/php.ini
date.timezone = 'Africa/Nairobi'
For the changes to kick in, restart the Apache service
$ sudo systemctl restart apache2
Step 3: Install MariaDB database server
Next, we are going to install MariaDB database as our preferred database server for storing user data and storing other metrics.
Install MariaDB Server packages by running the following command:
$ sudo apt install mariadb-server
Once installed, be sure to harden your database server using the command:
$ sudo mysql_secure_installation
Begin by setting the root password.
Then type 'Y' for all the remaining prompts:
Step 4: Create Zabbix user and database
Next, we create a database user for the Zabbix server. You will need to first log in to the MariaDB instance:
$ sudo mysql -u root -p
Create a Zabbix user and database as shown and grant all privileges to the user as follows:
CREATE DATABASE zabbix_db character set utf8 collate utf8_bin; CREATE USER 'zabbix_user'@'localhost' IDENTIFIED BY 'P@ssword321'; GRANT ALL PRIVILEGES ON zabbix_db.* TO 'zabbix_user'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;
Step 5: Enable Zabbix repository
To add Zabbix repository to your system, first download the Zabbix release Debian package using the wget command.
$ wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb
We are using Zabbix 5.01 version which is latest at the time of writing this guide.
Then, to enable the Zabbix repository, type:
$ sudo dpkg -i zabbix-release_5.0-1+focal_all.deb
To synchronize the newly added repository with the system, update the package lists
$ sudo apt update
Step 6: Install Zabbix Server on Ubuntu 20.04
To install the Zabbix server, we will install the zabbix-server-mysql package that provides MySQL support, the zabbix-frontend-php package that provides a web interface for the server, alongside zabbix-agent for shipping metrics and the zabbix-apache-conf package for Apache.
$ sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent zabbix-apache-conf
Step 7: Configure Zabbix server
With Zabbix installed, some additional tweaks are required. The configuration file is located at /etc/zabbix/zabbix_server.conf path. So open the file.
$ sudo vim /etc/zabbix/zabbix_server.conf
Update your database configurations as per your database user settings
DBHost=localhost DBName=zabbix_db DBUser=zabbix_user DBPassword=P@ssword321
Then load the default schema of the Zabbix database.
$ cd /usr/share/doc/zabbix-server-mysql $ zcat create.sql.gz | mysql -u zabbix_user -p zabbix_db
You will be required to provide your password, so go ahead and provide it.
Now, enable the Zabbix service to start on system boot and restart service to apply the new settings.
$ sudo systemctl enable zabbix-server
$ sudo systemctl restart zabbix-server
You can verify the status of Zabbix using the command:
$ sudo systemctl status zabbix-server
Zabbix also creates its own Apache configuration file /etc/zabbix/apache.conf and creates a link to the Apache configuration directory. Use the command below to restart Apache services.
$ sudo systemctl restart apache2
Also verify that Apache is running:
$ sudo systemctl status apache2
Your system is now ready for Zabbix installation.
Step 6: Configure the firewall
If you are behind a firewall, you need to allow Zabbix ports 10050 and 10051 and HTTP. Run the commands below to allow the ports:
$ sudo ufw allow 80/tcp
$ sudo ufw allow 10050/tcp
$ sudo ufw 10051
Then reload your firewall service to apply the changes made above:
$ sudo ufw reload
Step 7: Complete Zabbix installation on a browser
We are all set now. The only thing remaining is to complete the installation on a web browser. So, launch your browser and navigate to the address shown:
You get a welcome page shown below. Just click next to proceed to the next step.
Check to ensure that all prerequisites are fulfilled by the server and click on the Next step button.
In the next step, provide the database credentials that you provided when creating a database for Zabbix in Step 4 and click on the Next step button.
For the Zabbix Server details, provide your server hostname and IP address, then click the 'Next step' button again.
You will get a pre-installation summary as shown. Ensure that all the configuration parameters are correct then click on the Next step button.
Once the installation has been completed successfully, you should see the screen below:
Click on the Finish button. You will be taken to Zabbix front-end login page shown below:
Login with the following default credentials:
After you successfully login, you will see the Zabbix dashboard as shown below:
And that's it! You can now begin adding your hosts to the monitoring server to keep an eye on their performance. In this guide, we have shown you how to install Zabbix server on Ubuntu 20.04 system.