How to Install Zabbix Server on Debian 11 Server Monitoring Tutorial

How to Install Zabbix Server on Debian 11 Server Monitoring. In this tutorial we will learn what Zabbix is and move onto installation phase on Debian 11. Let’s get started. 

Simple installing, configuring and deploying applications on the cloud server is not enough for any system administrator. It is also essential to have a centralized monitoring tool to easily monitor the performance of all the servers from a centralized location. This is where the monitoring tools come into the picture. Monitoring tools allow you to monitor system resources including, RAM, CPU, input/output, network, disk usage, processes, etc.

What is Zabbix

Zabbix is a free, open source and enterprise class monitoring solution for network monitoring and application monitoring of millions of metrics. With Zabbix, you can monitor networks, servers, virtual machines (VM) and cloud services. Zabbix provides a simple and user friendly web interface that helps you to monitor multiple servers from the web browser. It works on the client server model and is capable of monitoring millions of metrics from tens of thousands of servers.

Follow this post to guide you how to install the Zabbix Monitoring server on Debian 11.

Install Zabbix Server on Debian 11 Server Monitoring

Getting Started

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, create a dedicated 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 Server

You will also need to install the Apache web server , MariaDB, PHP server and other PHP extensions on your server. You can install it 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 installing the LAMP server, start and enable the Apache and MariaDB service using the following command:

				
					systemctl start apache2 mariadb
systemctl enable apache2 mariadb

				
			

Create a Zabbix Database

Zabbix uses a MariaDB as a database backend. So you will need to create a database and user for Zabbix.

First, connect to the MariaDB shell with the following command:

				
					mysql
				
			

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

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

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

				
					flush privileges;
exit;
				
			

Install Zabbix on Debian 11

By default, the latest version of Zabbix is not included in the Debian 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.3.tar.gz
				
			

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

				
					tar -xvzf zabbix-6.0.3.tar.gz
				
			

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

				
					cd zabbix-6.0.3
./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>                    *
***********************************************************

				
			

Please install the Zabbix with the following command:

				
					make install
				
			

Configure Zabbix

After the Zabbix installation, 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.3/database/mysql/
mysql -u zabbixadmin -p zabbixdb < schema.sql
mysql -u zabbixadmin -p zabbixdb < images.sql
mysql -u zabbixadmin -p zabbixdb < data.sql
				
			

Next, edit the Zabbix configuration file:

				
					nano /usr/local/etc/zabbix_server.conf
				
			

Define your database settings and log file as shown below:

				
					DBHost=localhost
DBName=zabbixdb
DBUser=zabbixadmin
DBPassword=securepassword

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 Service File for Zabbix

Next, you will need to create a systemd service file to manage the Zabbix service. You can create the systemd service file for the 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 the 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 status, run the following command:

				
					systemctl status zabbix-server
				
			

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 Wed 2022-04-06 11:22:01 UTC; 24s ago
    Process: 36556 ExecStart=/usr/local/sbin/zabbix_server (code=exited, status=0/SUCCESS)
   Main PID: 36556 (code=exited, status=0/SUCCESS)
      Tasks: 48 (limit: 4679)
     Memory: 37.8M
        CPU: 292ms
     CGroup: /system.slice/zabbix-server.service
             ├─36563 /usr/local/sbin/zabbix_server
             ├─36572 /usr/local/sbin/zabbix_server: ha manager
             ├─36573 /usr/local/sbin/zabbix_server: service manager #1 [processed 0 events, updated 0 event tags, deleted 0 problems, synced >
             ├─36574 /usr/local/sbin/zabbix_server: configuration syncer [synced configuration in 0.184480 sec, idle 60 sec]
             ├─36579 /usr/local/sbin/zabbix_server: alert manager #1 [sent 0, failed 0 alerts, idle 5.005416 sec during 5.005585 sec]
             ├─36580 /usr/local/sbin/zabbix_server: alerter #1 started
             ├─36581 /usr/local/sbin/zabbix_server: alerter #2 started
             ├─36582 /usr/local/sbin/zabbix_server: alerter #3 started
             ├─36583 /usr/local/sbin/zabbix_server: preprocessing manager #1 [queued 0, processed 5 values, idle 5.005971 sec during 5.006203>
             ├─36584 /usr/local/sbin/zabbix_server: preprocessing worker #1 started
             ├─36585 /usr/local/sbin/zabbix_server: preprocessing worker #2 started
             ├─36586 /usr/local/sbin/zabbix_server: preprocessing worker #3 started

				
			

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

				
					systemctl status zabbix-agent
				
			

You will get the following output:

				
					● zabbix-agent.service - Zabbix Agent
     Loaded: loaded (/etc/systemd/system/zabbix-agent.service; disabled; vendor preset: enabled)
     Active: active (exited) since Wed 2022-04-06 11:22:01 UTC; 2min 7s ago
    Process: 36557 ExecStart=/usr/local/sbin/zabbix_agentd (code=exited, status=0/SUCCESS)
   Main PID: 36557 (code=exited, status=0/SUCCESS)
      Tasks: 6 (limit: 4679)
     Memory: 3.2M
        CPU: 116ms
     CGroup: /system.slice/zabbix-agent.service
             ├─36559 /usr/local/sbin/zabbix_agentd
             ├─36561 /usr/local/sbin/zabbix_agentd: collector [idle 1 sec]
             ├─36562 /usr/local/sbin/zabbix_agentd: listener #1 [waiting for connection]
             ├─36564 /usr/local/sbin/zabbix_agentd: listener #2 [waiting for connection]
             ├─36565 /usr/local/sbin/zabbix_agentd: listener #3 [waiting for connection]
             └─36566 /usr/local/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Apr 06 11:22:01 debian11 systemd[1]: Starting Zabbix Agent...
Apr 06 11:22:01 debian11 systemd[1]: Finished Zabbix Agent.

				
			

Configure Apache for Zabbix

Next, you will need to configure Apache 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 ~/zabbix-6.0.3/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 module 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 tweak some recommended 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
				
			

You can now check the status of the Apache with the following command:

				
					systemctl status apache2
				
			

You will get the following output:

				
					● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-04-06 11:25:51 UTC; 4s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 36680 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 36685 (apache2)
      Tasks: 6 (limit: 4679)
     Memory: 11.1M
        CPU: 95ms
     CGroup: /system.slice/apache2.service
             ├─36685 /usr/sbin/apache2 -k start
             ├─36686 /usr/sbin/apache2 -k start
             ├─36687 /usr/sbin/apache2 -k start
             ├─36688 /usr/sbin/apache2 -k start
             ├─36689 /usr/sbin/apache2 -k start
             └─36690 /usr/sbin/apache2 -k start

				
			

Access Zabbix Web Interface

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:

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

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

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

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

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:

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

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:

How to Install Zabbix Server on Debian 11 Server Monitoring Conclusion

In this post, we explained how to install and configure the Zabbix monitoring server on Debian 11. You can now add your remote servers from the Zabbix dashboard and start monitoring them from the central location.

 

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