How to Install Zabbix Server on Ubuntu 20.04 Server Monitoring

How to Install Zabbix Server on Ubuntu 20.04 Server Monitoring. In this tutorial we will introduce Zabbix monitoring, it’s features and major advantages then move onto installation phase on Ubuntu 20.04 server. Let’s get started.

Having a centralized monitoring tool is essential for monitoring the performance of your entire IT Infrastructure. Monitoring tools can not only prevent incidents, but also allows you to detect them faster whenever they happen. Using monitoring tool, you can monitor system resources such as, RAM, CPU, input/output, network, disk usage, and processes of all multiple servers from the central location.

What Is Zabbix Monitoring?

Install Zabbix server on Ubuntu 20.04

Zabbix, an open source monitoring software, is used for diverse IT components, like networks, servers, virtual machines (VMs) and cloud services. With the help of this software, you can effortlessly monitor metrics, including network utilization, CPU load, and disc space consumption. The operations can be performed on Linux, macOS, and other operating systems.

You can deploy software for both agent based and agentless monitoring. While agents can be installed on IT components for performance checking and data collection, agentless uses existing resources in a system or device to imitate agents. When you used agent based monitoring, the reports are centralized in a Zabbix management server. Therefore, whenever there are any issues concerning what is monitored, the system immediately notifies and alerts the user.

Furthermore, its web based GUI allows you to view your IT environment through customizable dashboards based on widgets, graphs, network maps, slideshows, and reports.

Features of Zabbix

  • Data Gathering –  where you can check performance bottlenecks and the availability of an application.
  • Alerting System – any issues occurring in the network servers are immediately notified to the user. It uses macro variables in the notifications with which you can receive alert messages via email, SMS, and a lot more.
  • Multiple Visualization Options – with the help of Zabbix, you can create custom graphs that enable you to combine several items into a single group. Since the reports are created using this tool, you can analyze the issues effortlessly.
  • Real Time Graphing – this tool provides real time monitoring of the network servers and applications to detect and analyze any performance issues. Since the tool has an in built feature of creating a graph in real time, you can acquire every file in a single place.
  • Effortless Configuration – individuals and organizations use Zabbix for monitoring purposes as the tool allow users to add monitoring device known as hosts. This host makes the monitoring activity and application of templates effortless.
  • Data Storage – All the data in Zabbix is stored in its database. It is also efficient in maintaining configurable history.
  • Efficient Web Interface – it offers a web interface developed in PHP language. It enables you to access the interface from any location. Moreover, you can audit the logs generated by the web interface effortlessly.

Benefits Of Zabbix Monitoring

Zabbix is highly beneficial because of the following reasons:

Zabbix Agent

Zabbix is a solid tool that you can use to monitor the networks and servers. It also helps you to manage the database. By enabling its agent based monitoring, you can acquire different functionality for monitoring the network. It also increases the capacity of storing the database.

Easy To Use GUI

The GUI offered by Zabbix is easy to use. It means you can effortlessly monitor the networks and servers for finding performance bottlenecks. It also provides functionality to configure the tool and present the visualizations. Therefore, with the help of this tool’s GUI, the entire IT environment can be visualized.

Saves Money

Both individuals and organizations can use this open source monitoring tool. They can also access its source code quite effortlessly. An organization can reduce its operating costs. Moreover, the configuration and setup costs are also very fast and efficient.

Remedial and Notification Module

The notifications and alerts of any unusual behavior in the network can be acquired from this tool. With the help of this feature, users can send the information and take necessary actions immediately. It provides multiple options to users for sending or receiving notifications. It includes SMS, email, Jabber, and many more. Therefore, you can rest assured of this tool for all your IT operations.

Follow this post to see how to install Zabbix Monitoring on Ubuntu 20.04.

How to Install Zabbix Ubuntu 20.04

Prerequisites

  • A server running Ubuntu 20.04 with SSH access.
  • A root user or a user with sudo privileges.

Install Required Dependencies

Before starting, you will need to install some dependencies required to install Zabbix on your server. You can install all the dependencies by running the following command:

				
					apt-get install build-essential libmariadb-dev sudo libxml2-dev snmp libsnmp-dev libcurl4-openssl-dev libevent-dev libpcre3-dev libxml2-dev libmariadb-dev libopenipmi-dev pkg-config -y
				
			

Once all the dependencies are installed, you will need to create a separate user and required directory for Zabbix:

				
					useradd -r -d /var/lib/zabbix -s /sbin/nologin -M zabbix
mkdir /var/lib/zabbix
chown -R zabbix:zabbix /var/lib/zabbix
				
			

Install LAMP Stack

You will also need to install the LAMP Stack components on your server. You can install all components by running the following command:

				
					apt-get install apache2 mariadb-server php-gd php-xml php-bcmath php-mbstring libapache2-mod-php php-ldap php-mysql -y
				
			

After the successful installation, start and enable the Apache and MariaDB service using the following command:

				
					systemctl start apache2 mariadb
systemctl enable apache2 mariadb
				
			

Create a MariaDB Database

Zabbix server uses a MariaDB as a database backend. So you will need to create a database and user for Zabbix. First, connect to the MariaDB interface with the following command:

				
					mysql
				
			

Once you are connected to the MariaDB, create a database and user with the following command:

				
					create database zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to zabbix@localhost identified by 'securepassword';
				
			

Next, flush the privileges and exit from the MariaDB shell with the following command:

				
					flush privileges;
exit;
				
			

Install Zabbix Server

Now you are ready to Install Zabbix Server on Ubuntu 20.04. By default, the latest version of Zabbix is not included in the Ubuntu default repository. So it is a good idea to compile the Zabbix from the source.

First, download the latest version of Zabbix using the following command:

				
					wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.4.tar.gz
				
			

Once the Zabbix is downloaded, extract the downloaded file with the following command:

				
					tar -xvzf zabbix-6.0.4.tar.gz
				
			

Next, navigate to the Zabbix directory and configure it with the following command:

				
					cd zabbix-6.0.4
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
				
			

You will get the following output:

				
					  Enable agent 2:        no

  Enable web service:    no

  Enable Java gateway:   no

  LDAP support:          no
  IPv6 support:          yes

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************

				
			

Next, install the Zabbix with the following command:

				
					make install
				
			

Configure Zabbix

Here you will need to import Schema, Images and data to the Zabbix database. You can import them with the following commands:

				
					cd ~/zabbix-6.0.4/database/mysql/
mysql -u zabbix -p zabbix < schema.sql
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql
				
			

Next, edit the Zabbix configuration file and define your database settings:

				
					nano /usr/local/etc/zabbix_server.conf
				
			

Define your database settings and log file as shown below:

				
					DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=securepassword
AllowUnsupportedDBVersions=1
LogFile=/var/log/zabbix_server.log

				
			

Save and close the file then create a Zabbix log file and set proper ownership:

				
					touch /var/log/zabbix_server.log
chown zabbix:zabbix /var/log/zabbix_server.log
				
			

Create a Systemd Service File for Zabbix

Next, you will need to create a systemd service file to manage Zabbix service. You can create the systemd service file for Zabbix server with the following command:

				
					nano /etc/systemd/system/zabbix-server.service
				
			

Add the following lines:

				
					[Unit]
Description=Zabbix Server
After=syslog.target network.target mariadb.service
 
[Service]
Type=oneshot
User=zabbix
ExecStart=/usr/local/sbin/zabbix_server
ExecReload=/usr/local/sbin/zabbix_server -R config_cache_reload
RemainAfterExit=yes
PIDFile=/var/run/zabbix/zabbix_server.pid
 
[Install]
WantedBy=multi-user.target

				
			

Save and close the file then create a systemd service file for Zabbix agent:

				
					nano /etc/systemd/system/zabbix-agent.service
				
			

Add the following lines:

				
					[Unit]
Description=Zabbix Agent
After=syslog.target network.target
 
[Service]
Type=oneshot
User=zabbix
ExecStart=/usr/local/sbin/zabbix_agentd
RemainAfterExit=yes
PIDFile=/var/run/zabbix/zabbix_agent.pid

 
[Install]
WantedBy=multi-user.target

				
			

Save and close the file then reload the systemd daemon to apply the changes:

				
					systemctl daemon-reload
				
			

Now, start and enable the Zabbix server and agent service using the following command:

				
					systemctl start zabbix-server zabbix-agent
systemctl enable zabbix-server zabbix-agent
				
			

To check the Zabbix server and agent status, run the following command:

				
					systemctl status zabbix-server zabbix-agent
				
			

You will get the following output:

				
					● zabbix-server.service - Zabbix Server
     Loaded: loaded (/etc/systemd/system/zabbix-server.service; disabled; vendor preset: enabled)
     Active: active (exited) since Mon 2022-06-13 12:04:03 UTC; 32s ago
    Process: 34564 ExecStart=/usr/local/sbin/zabbix_server (code=exited, status=0/SUCCESS)
   Main PID: 34564 (code=exited, status=0/SUCCESS)

Jun 13 12:04:01 ubuntu2004 systemd[1]: Starting Zabbix Server...
Jun 13 12:04:03 ubuntu2004 systemd[1]: Finished Zabbix Server.

● zabbix-agent.service - Zabbix Agent
     Loaded: loaded (/etc/systemd/system/zabbix-agent.service; disabled; vendor preset: enabled)
     Active: active (exited) since Mon 2022-06-13 12:04:01 UTC; 34s ago
    Process: 34565 ExecStart=/usr/local/sbin/zabbix_agentd (code=exited, status=0/SUCCESS)
   Main PID: 34565 (code=exited, status=0/SUCCESS)
      Tasks: 6 (limit: 2348)
     Memory: 4.6M
     CGroup: /system.slice/zabbix-agent.service
             ├─34576 /usr/local/sbin/zabbix_agentd
             ├─34577 /usr/local/sbin/zabbix_agentd: collector [idle 1 sec]
             ├─34578 /usr/local/sbin/zabbix_agentd: listener #1 [waiting for connection]
             ├─34581 /usr/local/sbin/zabbix_agentd: listener #2 [waiting for connection]
             ├─34582 /usr/local/sbin/zabbix_agentd: listener #3 [waiting for connection]
             └─34583 /usr/local/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

				
			

Create an Apache Virtual Host for Zabbix

Next in this article about how to Install Zabbix Server on Ubuntu 20.04 Server Monitoring is to create an Apache virtual host configuration file for deploying Zabbix on the internet. First, create a directory for Zabbix inside the Apache web root:

				
					mkdir /var/www/html/zabbix
				
			

Next, copy all Zabbix files from the Zabbix source to the Apache web root directory:

				
					cp -ar /root/zabbix-6.0.4/ui/* /var/www/html/zabbix/
				
			

Next, change the ownership of the Zabbix directory:

				
					chown -R www-data:www-data /var/www/html/zabbix/
				
			

Next, enable the Opcache in PHP with the following command:

				
					echo "opcache.enable=0" >> /etc/php/7.4/mods-available/opcache.ini
				
			

Next, edit the PHP configuration file and modify some default settings:

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

Change the following settings:

				
					post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = UTC
				
			

Save and close the file then restart the Apache service to apply the changes:

				
					systemctl restart apache2
				
			

Access Zabbix Web Installation Wizard

1. Now, open your web browser and access the Zabbix web installation wizard using the URL http://your-server-ip/zabbix. You should see the Zabbix language selection screen:

2. Select your language and click on the Next step button. You should see the Zabbix prerequisites check screen:

3. Make sure all required packages are installed then click on the Next step button. You should see the Zabbix database configuration screen:

4. Provide your database settings then click on the Next step button. You should see the Zabbix server settings screen:

5. Provide your Zabbix server name, timezone, theme and click on the Next step button. You should see the Zabbix installation summary screen:

6. Verify all the configuration details and click on the Next step button to start the installation. Once the Zabbix is installed, you should see the following screen:

7. Click on the Finish button. You should see the Zabbix login screen:

8. Provide default admin username as Admin and Password as zabbix then click on the Sign in button. You should see the Zabbix dashboard on the following screen:

Great job! We have learned how to Install Zabbix Server on Ubuntu 20.04 Server Monitoring, we can now procced to conclusion.

How to Install Zabbix Server on Ubuntu 20.04 Server Monitoring Conclusion

In this post, we explained how to install and configure Zabbix monitoring server on Ubuntu 20.04. You now have a fully configured Zabbix monitoring center where you can see your entire server information as well as receive notifications about any issues that may arise. You can now install Zabbix agents on remote servers, add them on Zabbix server via Zabbix dashboard and start monitoring them via web browser.

It is always a good idea to choose an open source monitoring solution and monitor all server yourself without any additional monthly fees. With Zabbix, you can use it on an unlimited number of servers without any licensing cost. Zabbix also offers tons features that help ease the process of monitoring and debugging threats and issues. I hope this guide will helps you to deploy your own monitoring system in your organizations.

Also have a look at alternatives to Zabbix like Nagios Core, Grafana, Solar Winds or Prometheus.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x