×


Step by Step process to install and configure Zabbix monitoring server on Ubuntu ?

Zabbix is an open-source utility for monitoring servers, network devices, network services, and applications. It helps to keep an eye on the network infrastructure and detect issues with hardware or software programs. 

Zabbix tools gather information from the devices being monitored and send it to a central authority.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Server Monitoring tasks.

In this context, we shall look into how to install and configure Zabbix on Linux to monitor servers health. 


More about Zabbix?

Zabbix has two major components: 

i. Zabbix server

ii. Zabbix agent. 

Zabbix server is the main component that receives the collected data from the monitored devices. Zabbix agent collects data from the devices you want to monitor and forward it to the Zabbix server.


How to install Zabbix on Ubuntu ?

Here, will be using two Linux machines (Ubuntu 20.04 LTS ); one as a monitoring server on which we will install and configure the Zabbix server and the other as a client that we want to monitor. 

On the client machine, we will install the Zabbix agent that will collect data and report to the Zabbix server. 

We will also install the Zabbix agent on the Zabbix monitoring server so that it can also monitor itself.

To proceed with this setup, you need to follow the steps given below.


1. Installing Pre-requisites

Zabbix uses MySQL as a backend database for storing the collected information while it uses Apache and PHP as the frontend for serving the web interface. 

On the machine that you want to configure as Zabbix monitoring server, you will need to install:

i. Apache 1.3.12 or later

ii. PHP 7.2.5 or later

iii. MySQL: 5.5 or 8.0.x


i. Installing Apache Web Server

Apache web server will be used to serve the Zabbix web interface. Execute the following commands in Terminal to install it:

$ sudo apt update
$ sudo apt install apache2

To verify if Apache service is enabled and running. Issue the below command:

$ sudo systemctl status apache2

If the service is not enabled or running, you can manually enable and start is using the below commands:

$ sudo systemctl enable apache2
$ sudo systemctl start apache2

Now if a firewall is running on your system, allow the Apache through it:

$ sudo ufw allow 'Apache'

ii. Installing and Configuring PHP Packages

Now we will install PHP along with few dependencies. Issue the following command in Terminal to do this:

$ sudo apt install php-cli php-common php-dev php-pear php-gd php-mbstring php-mysql php-xml php-bcmath libapache2-mod-php

After the installation of PHP packages is completed, we will need to do a little configuration. Edit the "php.ini" configuration file for Apache2:

$ sudo nano /etc/php/7.4/apache2/php.ini

Make the following changes in the file. Remove the semicolon (;) from the date.timezone line:

date.timezone = <Your_Time_Zone>
max_execution_time = 600 
max_input_time = 600 
memory_limit = 256M 
post_max_size = 32M 
upload_max_filesize = 16M

Replace <Your_Time_Zone> with the time zone of your server's location.

Now edit the "php.ini" configuration file for PHP cli:

$ sudo nano /etc/php/7.4/cli/php.ini

Make the same above changes in this file, then save, and close it.


iii. Installing and Configuring MySQL Server

Here, we will install and configure MySQL server to store the data collected by the Zabbix server from the agents. The version of MySQL currently available on Ubuntu 20.04 LTS repositories is 8.0. 

Now, run the command to install MySQL server:

$ sudo apt install mysql-server

Once the installation is completed, issue the below command to secure the SQL server. It will set the root password for the MySQL server along with some other security options:

$ sudo mysql_secure_installation

Hit 'y' for all of the prompts. When asked to set the root password, enter the password twice.


2. Installing and Configuring Zabbix

Now we will install and configure Zabbix on the same machine where we have installed all the prerequisites (Apache, MySQL, and PHP).

i. Install Zabbix Repository

First, we will need to download and install the Zabbix official repository to our system. Issue the below commands in Terminal to do so:

$ wget https://repo.zabbix.com/zabbix/5.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.2-1+ubuntu20.04_all.deb
$ sudo dpkg -i zabbix-release_5.2-1+ubuntu20.04_all.deb

Now update the local repository to include the Zabbix repository:

$ sudo apt update

Once the repository is updated, you can install Zabbix using the below command:

$ sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent

It will also install the Zabbix agent that will let the Zabbix server to monitor itself.


ii. Import Zabbix Schema

Now we will need to import the Zabbix initial schema to the newly created “Zabbix” database:

$ zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

Provide the password for the MySQL user “Zabbix” you created during the Zabbix database creation.


iii. Configuring the Database for Zabbix Server

Now we will create a new database on MySQL and configure it for Zabbix server.

a. Create the Database

Login to MYSQL console as a root user. Issue the below command to do so:

$ sudo mysql -u root -p

Now to create a database, issue the following command:

create database zabbix character set utf8 collate utf8_bin;


Then create a user along with a password and grant it privileges to access the database:

grant all privileges on zabbix.* to zabbix@'localhost' identified by 'PASSWORD';


Now issue the below command to apply the changes:

flush privileges;

Then exit the console:

exit

Now the database and the user have been created for the Zabbix server.


b. Configure the Database

In order to point the Zabbix server to the database, edit the Zabbix configuration file zabbix_server.conf using the below command:

$ sudo nano /etc/Zabbix/ zabbix_server.conf

Look for the following line:

# DBPassword=

Uncomment this line and set its value to the password for the MySQL user “Zabbix” you created during the Zabbix database creation in the previous step.


Then save and close the zabbix_server.conf file.


Once you are done with the Zabbix configuration, restart the Apache server:

$ sudo systemctl restart apache2.service

Then start and enable the Zabbix server:

$ systemctl start zabbix-server
$ systemctl enable zabbix-server

Also verify if the Zabbix server is active and running properly:

$ systemctl status zabbix-server


3. Configuring Zabbix Frontend

Now let's configure the browser-based Zabbix frontend. 

i. Open any web browser and go to the following address:

http://zabbix-server-hostname-or-IP/zabbix

ii. A wizard with a welcome screen will appear. Click Next step.

iii. Next, the wizard will check for all the pre-requisites. Make sure all the values for the pre-requisites are OK and then click Next step.

iv. When the following screen shows up, enter the password for “Zabbix” user you configured earlier and then click Next step.

v. Now, you will be asked to enter the Zabbix server details. Provide the Zabbix server hostname or IP address or you can also leave the details as defaults. Then click Next step.

vi. Then select your time zone and theme for the web interface. Then click Next step.

vii. Now, you will see the Pre-installation summary for review. If you are ok with everything, click Next step.

viii. Next, you will be informed that the installation of the Zabbix frontend has been completed. Click Finish to close the installation wizard. Then login to the Zabbix server using the following default credentials:

Username: Admin
Password: zabbix

After logging in, you will see the following Dashboard with one host available in it which is the Zabbix server itself as we have also installed the agent on it. Now the Zabbix server will start monitoring itself.


4. Installing and Configuring Zabbix Agent on Client

Now on the client machine, we will install agent and connect it to the Zabbix server.

a. Install and Configure Agent

i. Issue the below commands in Terminal to install Zabbix repository:

$ wget https://repo.zabbix.com/zabbix/5.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.2-1+ubuntu20.04_all.deb
$ sudo dpkg -i zabbix-release_5.2-1+ubuntu20.04_all.deb

ii. Then install the agent:

$ sudo apt install zabbix-agent

iii. Edit the Zabbix agent configuration file:

$ sudo nano /etc/zabbix/zabbix_agentd.conf

Search the below entry in the file:

Server=127.0.0.1

Replace it with the Zabbix server’s IP address which in our case would be:

Server=192.168.72.157

Then save and close the Zabbix agent configuration file.


iv. Start and enable the Zabbix service:

$ sudo systemctl start zabbix-agent
$ sudo systemctl enable zabbix-agent

Then verify whether the Zabbix agent is active and running properly.

$ sudo systemctl status zabbix-agent

v. Also, allow port 10050 through the firewall:

$ sudo ufw allow 10050/tcp


b. Add Host to the Zabbix Server

In the previous section, we installed the agent on the client machine. Now, we will add this machine in the Zabbix server.

i. Login to the Zabbix server web interface by visiting:

http://zabbix-server-hostname-or-IP/zabbix

ii. Go to Configuration > Hosts from the left navigation bar. Then click Create host.

iii. Type the hostname of the Zabbix agent machine and then add it to the Linux servers group.

iv. Type the IP address of the Zabbix agent machine.

v. Then go to the Templates tab, select Templates/Operating systems.

vi. From the list, select Linux by Zabbix agent and then click Select.

vii. Then click the Add button.

viii. Now click the Add button at the bottom of the web interface to add this host to the Zabbix server. Once added, you will be notified with the Host added ix. notification at the top of window.

x. If you head over to Dashboard, you will see two hosts added to your Zabbix server; one is the Zabbix server itself and the other is the client machine.


[Need urgent assistance to set up Zabbix Server? We are available to help you. ]


Conclusion

This article will guide you on how to install and configure the Zabbix server on #Linux. You have also learned how to install and configure the Zabbix agent on the Zabbix server and the client #machines. Now you can easily keep track of the servers and monitor their health.

Zabbix server is the central process of #Zabbix software. The server performs the polling and trapping of data, it calculates triggers, sends notifications to users.

The server can itself remotely check networked services (such as web servers and mail servers) using simple service checks.

You can now start the Zabbix server and agent by running the commands:

sudo systemctl start zabbix-server.

sudo systemctl start zabbix-agent.