“Zabbix is the ultimate enterprise-level software designed for real-time monitoring of millions of metrics collected from tens of thousands of servers, virtual machines, and network devices.” It is capable of monitoring not only Linux but Windows, Solaris, IBM AIX. It has the capabilities of monitoring applications, services, databases and much more.
We are going to install Zabbix Server in the latest Debian 11 / Debian 10 in this guide. Kindly follow through as we get it done together.
The dependencies for this setup are:
- Nginx webserver
- PHP with required extensions
- MySQL/ MariaDB database server
Before you go further consider upgrading your operating system
sudo apt update && sudo apt -y full-upgrade
[ -f /var/run/reboot-required ] && sudo reboot -f
Step 1: Add Zabbix repository on Debian 11 / Debian 10
Update your package repo cache and install wget.
sudo apt update
sudo apt install wget -y
Use the commands shared in this step to add Zabbix Server APT repository to your Debian system.
Add Zabbix repository on Debian 11:
wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-2+debian11_all.deb
sudo dpkg -i zabbix-release_5.0-2+debian11_all.deb
sudo apt update
Add Zabbix repository on Debian 10:
wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1+buster_all.deb
sudo dpkg -i zabbix-release_5.0-1+buster_all.deb
sudo apt update
Add Zabbix repository on Debian 9:
wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1+stretch_all.deb
sudo dpkg -i zabbix-release_5.0-1+stretch_all.deb
sudo apt update
Step 2: Install Zabbix Server on Debian 11 / Debian 10
Zabbix comes with three components, the Server, Proxy and Frontend. The proxy is optional.
Install Zabbix Server
This will install MariaDB database server for Zabbix server.
sudo apt install zabbix-server-mysql
sudo apt install mariadb-server
Check the installed version by running the command below
$ mariadb --version
mariadb Ver 15.1 Distrib 10.3.22-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Step 3: Configure and create Zabbix Server Database
Secure your Database
Run the command below and say “Yes(Y)” to remove anonymous users, remove test databases and to disable remote root login.
$ sudo mysql_secure_installation
Enter current password for root (enter for none):
Switch to unix_socket authentication [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
Login to MariaDB
Access MariaDB shell as root user
mysql -u root -p
Authenticate using the password assigned earlier.
$ sudo mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 55
Server version: 10.5.12-MariaDB-0+deb11u1 Debian 11
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
Create Zabbix DataBase and Zabbix User:
CREATE DATABASE zabbixdb character set utf8 collate utf8_bin;
GRANT ALL PRIVILEGES ON zabbixdb.* TO userzabbix@localhost IDENTIFIED by 'SafePassWord';
FLUSH PRIVILEGES;
QUIT;
Import data
Now import initial schema and data for the server with MySQL:
sudo zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uuserzabbix -p'SafePassWord' zabbixdb
Step 4: Install Zabbix frontend on Debian 11 / Debian 10
This will install Nginx and PHP.
sudo apt install zabbix-frontend-php zabbix-nginx-conf
Check installed versions of Nginx and PHP
$ nginx -v
nginx version: nginx/1.14.2
$ php -v
PHP 7.4.25 (cli) (built: Oct 23 2021 21:53:50) ( NTS )
Configure PHP’s date.timezone parameter that Zabbix uses in its setup
sudo vim /etc/php/*/fpm/php.ini
## Navigate till "Date" category
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone =Africa/Nairobi ## Set your timezone here as shown
Restart php-fpm
sudo systemctl restart php*-fpm.service
Start and enable Nginx
sudo systemctl enable nginx
sudo systemctl start nginx
Configure Nginx
Zabbix creates its own Nginx configuration file. Open and uncomment the “listen” and “server_name” parts as shown below
sudo vim /etc/nginx/conf.d/zabbix.conf
server {
listen 80; ## Uncomment this part
server_name zabbix.geeksforgeeks.org; ## Uncomment this part too and set correct domain name
Change port of the “default” Nginx file in Debian to listen on a different port so that it does not collide with Zabbix as configured above.
sudo vim /etc/nginx/sites-available/default
server {
listen 82 default_server; ## Change from 80 to 82
listen [::]:82 default_server; ## Change from 80 to 82 as well
Change permissions on Zabbix root folder
sudo chmod -R 775 /usr/share/zabbix/
Restart Nginx
sudo systemctl restart nginx
Confirm service status:
$ systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-12-31 18:41:57 UTC; 2min 41s ago
Docs: man:nginx(8)
Main PID: 26716 (nginx)
Tasks: 3 (limit: 2340)
Memory: 3.1M
CPU: 42ms
CGroup: /system.slice/nginx.service
├─26716 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─26719 nginx: worker process
└─26720 nginx: worker process
Dec 31 18:41:57 debian-bullseye-01 systemd[1]: Starting A high performance web server and a reverse proxy server...
Dec 31 18:41:57 debian-bullseye-01 systemd[1]: Started A high performance web server and a reverse proxy server.
Step 5: Configure the database for Zabbix server
Open the Zabbix server configuration file and make changes as shown below. If you had used different Database and User names, kindly update them accordingly.
$ sudo vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbixdb
DBUser=userzabbix
DBPassword=SafePassWord
Replace the values with your correct database settings.
Step 6: Install Zabbix Agent on Debian 11 / Debian 10
This agent will monitor the server itself but you can easily install
To install the agent, run
sudo apt -y install zabbix-agent
Start and enable Zabbix agent and server
sudo systemctl enable zabbix-server zabbix-agent
sudo systemctl start zabbix-server zabbix-agent
Step 7: Set up Zabbix Web Interface
Open up your favorite browser and enter the IP of your Zabbix Server. Mine is as shown below
http://172.17.37.54
You should see a page similar to the one illustrated below. Click “Next step“.
Make sure all pre-requisites record a green “OK” then click “Next step“
Enter the Database details we set up earlier and then click “Next step“
Input your Zabbix Server details
View the summary of your settings
Finish up the settings
Let us now Log in and proceed to the Dashboard. The default username is “Admin” and password is “zabbix“. This credential can be changed under the Administration tab once you log in.
Navigate to Administration > Users > Admin > Password > Change Password
Conclusion
Zabbix Server is now running on Nginx and we hope everything went well on your side. Thank you for taking the time on the blog.
You might also like