Monitoring with Zabbix
Zabbix is an open-source monitoring system for servers, network devices, and applications: it collects metrics (CPU load, memory, disk, network, service availability) and can alert you when something goes wrong. This article covers getting a Zabbix server running on an mHost VPS — with a one-click ready-made recipe or manually from the official repository — and connecting your first monitored host with an agent.
What you'll need
- An mHost VPS on one of: Ubuntu 22.04/24.04, Debian 11/12, or AlmaLinux/Rocky Linux 8/9 — for the manual install below; for the ready-made recipe, check the supported OS list in the recipes article.
- SSH access as
rootor a user withsudorights. - The server's public IP address — to open the Zabbix web interface in a browser.
- If you're also planning to monitor other mHost VPS's, you'll need SSH access to them too, for installing the agent.
Ready-made recipes: Zabbix in one click
VMmanager 6 has three ready-made recipes for Zabbix — installed in one click, without a single console command (for how to run recipes, see the "Ready-made VMmanager 6 recipes" article):
- Zabbix server — a full-featured monitoring server: Zabbix itself, the database, and the web interface in one recipe. Web interface login after install: username
Admin, passwordzabbix. - Zabbix agent2 linux — the agent for a server you want to bring under monitoring (installed separately on each monitored VPS).
- Zabbix proxy — a proxy in passive mode: collects metrics from remote nodes and forwards them to the Zabbix server, useful when monitoring a large number of servers or sites behind NAT.
Manually installing the Zabbix server
Below is an install of Zabbix 7.0 (the current LTS branch) with MariaDB and Apache from the official Zabbix repository.
Step 1. Add the official Zabbix repository
Ubuntu/Debian:
wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu24.04_all.deb
sudo dpkg -i zabbix-release_latest_7.0+ubuntu24.04_all.deb
sudo apt updateThe command above is for Ubuntu 24.04. For a different version, use this instead:
- Ubuntu 22.04 —
zabbix-release_latest_7.0+ubuntu22.04_all.debfrom.../ubuntu/pool/main/z/zabbix-release/ - Debian 12 (bookworm) —
zabbix-release_latest_7.0+debian12_all.debfrom.../debian/pool/main/z/zabbix-release/ - Debian 11 (bullseye) —
zabbix-release_latest_7.0+debian11_all.debfrom the same Debian folder
AlmaLinux/Rocky:
sudo rpm -Uvh https://repo.zabbix.com/zabbix/7.0/alma/9/x86_64/zabbix-release-latest-7.0.el9.noarch.rpmThe command above is for AlmaLinux 9. For a different OS/version, replace alma with rocky in the path if you're on Rocky Linux, and 9 with 8 if you're on version 8 (for example, .../rocky/8/x86_64/zabbix-release-latest-7.0.el8.noarch.rpm).
Step 2. Install MariaDB and the Zabbix packages
First, the database:
Ubuntu/Debian:
sudo apt install mariadb-serverAlmaLinux/Rocky:
sudo dnf install mariadb-serversudo systemctl enable --now mariadb
sudo mysql_secure_installationThe mysql_secure_installation script asks a few questions (set a root password, remove anonymous users, disallow remote root login, remove the test database) — you can answer Y to all of them, those are safe defaults.
Now the Zabbix packages themselves:
Ubuntu/Debian:
sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2AlmaLinux/Rocky:
sudo dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2zabbix-server-mysql— the Zabbix server itself, with MySQL/MariaDB support.zabbix-frontend-php/zabbix-web-mysql— the web interface (PHP); the needed PHP modules (mysqli, gd, bcmath, mbstring, etc.) are pulled in automatically as dependencies.zabbix-apache-conf— a ready-made Apache config for the frontend, already set with the right PHP limits (memory_limit,upload_max_filesize, etc.) — no manual php.ini tweaking needed.zabbix-sql-scripts— the database SQL schema for the next step.zabbix-selinux-policy— on AlmaLinux/Rocky, SELinux is enabled in enforcing mode by default; this package adds a ready-made policy so Zabbix and Apache can talk to each other without manual SELinux configuration.zabbix-agent2— the agent for monitoring this same VPS (useful in the add-a-host section below).
Step 3. Create the database
sudo mysql <<'EOF'
CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY '<password>';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
SET GLOBAL log_bin_trust_function_creators = 1;
EOFReplace <password> with your own password — you'll need it twice more: when importing the schema below, and in the server settings in step 4.
Import the database schema (the command will prompt for the password you just set):
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbixThe import takes anywhere from a few seconds to a couple of minutes — wait for it to return to the command prompt with no errors. After that, you can turn the temporary logging setting back off:
sudo mysql -e "SET GLOBAL log_bin_trust_function_creators = 0;"Step 4. Set the DB password, start the services, and open the ports
Open the server config:
sudo nano /etc/zabbix/zabbix_server.confFind the commented-out # DBPassword= line and add the same password you set in step 3 right below it:
DBPassword=<password>Start the services and enable them on boot:
Ubuntu/Debian:
sudo systemctl enable --now zabbix-server zabbix-agent2 apache2AlmaLinux/Rocky:
sudo systemctl enable --now zabbix-server zabbix-agent2 httpd php-fpmCheck that the server came up:
sudo systemctl status zabbix-server --no-pagerThe expected status is active (running). If not, check the log for the cause: sudo tail -n 30 /var/log/zabbix/zabbix_server.log.
Open the ports for the web interface:
Ubuntu/Debian (ufw):
sudo ufw allow 80/tcp
sudo ufw allow 443/tcpAlmaLinux/Rocky (firewalld):
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reloadPort 10051/tcp (trapper) is only needed if you're planning to add hosts on other VPS's — their agents will then reach out to this port on this server. For monitoring only this server, you don't have to open it externally; if you need it later, open it the same way:
Ubuntu/Debian (ufw):
sudo ufw allow 10051/tcpAlmaLinux/Rocky (firewalld):
sudo firewall-cmd --permanent --add-port=10051/tcp
sudo firewall-cmd --reloadStep 5. Finish setup in the web interface and change the password
Open http://<server-ip>/zabbix in a browser (for Apache this works the same on Ubuntu/Debian and on AlmaLinux/Rocky) — the web interface setup wizard will open:
- Welcome — pick the interface language, "Next".
- Check of pre-requisites — every item (PHP version,
memory_limit,post_max_size, the mysqli/bcmath/mbstring extensions, etc.) should be green: the packages from step 2 already set the right values, so there's no php.ini to fix by hand. - Configure DB connection — Database type:
MySQL; Database host:localhost; Database port — leave it at its default (with hostlocalhost, the frontend connects via a Unix socket, no TCP involved); Database name:zabbix; User:zabbix; Password — the one you set in step 3. - Settings — optionally a server name (shown in page titles) and a default time zone for the frontend — the time zone is configured right here, no need to dig into php.ini/apache.conf for it.
- Pre-installation summary — review it and click "Next".
- Install → "Finish".
- Log in — username
Admin, passwordzabbix.
Add a host and agent to monitor
Step 1. Install the agent on the VPS you want to monitor
If you'll be monitoring the same VPS that the Zabbix server is on, the agent (zabbix-agent2) is already installed from step 2 of the "Manually installing the Zabbix server" section above — no need to install it separately: skip straight to step 2 below (configuring the agent).
If you want to add a different mHost VPS to monitoring, add the same official Zabbix repository on it (step 1 of the "Manually installing the Zabbix server" section above) and install just the agent:
Ubuntu/Debian:
sudo apt install zabbix-agent2AlmaLinux/Rocky:
sudo dnf install zabbix-agent2Step 2. Configure the agent: Server, ServerActive, Hostname
sudo nano /etc/zabbix/zabbix_agent2.confIf the agent is on the same server as the Zabbix server, leave the file alone: out of the box it already has Server=127.0.0.1, ServerActive=127.0.0.1, and Hostname=Zabbix server set — by default, the agent is already configured to send data to the local server under the name of the host that Zabbix creates for itself during install (see step 3 below).
If the agent is on a different VPS, set these three parameters to the address of the VPS running the Zabbix server and a unique name for the new host:
Server=192.0.2.10
ServerActive=192.0.2.10
Hostname=vps-01192.0.2.10— replace with the actual IP address of the VPS running the Zabbix server.vps-01— any unique name; you'll add the host under this same name in the web interface in the next step.
Restart the agent and enable it on boot:
sudo systemctl restart zabbix-agent2
sudo systemctl enable zabbix-agent2Ubuntu/Debian (ufw):
sudo ufw allow 10050/tcpAlmaLinux/Rocky (firewalld):
sudo firewall-cmd --permanent --add-port=10050/tcp
sudo firewall-cmd --reloadStep 3. Add the host under Data collection → Hosts
In the Zabbix server's web interface, open Data collection → Hosts in the left-hand menu.
If you're monitoring the same server the Zabbix server is on, a host named Zabbix server is already there (created automatically during install, its name matching the agent config's default Hostname). Open it and check whether a template such as Linux by Zabbix agent is linked in the Templates field — add it if not.
If you're monitoring a separate VPS, click Create host and fill in:
- Host name — the same name you set in the agent's
Hostname(for example,vps-01). - Host groups — an existing group, or a name for a new one.
- Templates — for example, Linux by Zabbix agent.
- Interfaces → Agent — this VPS's IP address, port
10050.
Click Add.
Within a minute or two, the ZBX availability icon in the host list should turn green — meaning the server is now receiving data from the agent.
What's next
The full list of ready-made VMmanager 6 recipes is in the "Ready-made VMmanager 6 recipes" article. If you haven't logged in to the server's control panel yet, start with the "How to log in to VMmanager 6" article.