MHOSTMHOST

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 root or a user with sudo rights.
  • 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, password zabbix.
  • 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.
Important: the zabbix password on the "Zabbix server" recipe is a well-known default, not a secret. Change it right after your first login, before exposing the web interface to the outside world — see the password-change block in the first-login step below, which is the same whether you installed Zabbix via the recipe or manually.
Tip: the recipe is the fastest way to get Zabbix running, without a single console command. The rest of this article covers installing the same stack manually — useful if you need control over package versions, a database on a separate server, or if the recipe doesn't fit for some reason.

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.

Tip: check zabbix.com/download for your OS to confirm 7.0 is still the current LTS version. If Zabbix has already released a newer LTS in place of 7.0, substitute its number for 7.0 in the paths and package names below — the rest of the steps stay the same.

Step 1. Add the official Zabbix repository

Important: use only the official repo.zabbix.com repository. Zabbix versions from the distributions' own repositories (especially on Debian) are often outdated and unsupported by Zabbix.

Ubuntu/Debian:

bash
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 update

The 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.deb from .../ubuntu/pool/main/z/zabbix-release/
  • Debian 12 (bookworm) — zabbix-release_latest_7.0+debian12_all.deb from .../debian/pool/main/z/zabbix-release/
  • Debian 11 (bullseye) — zabbix-release_latest_7.0+debian11_all.deb from the same Debian folder

AlmaLinux/Rocky:

bash
sudo rpm -Uvh https://repo.zabbix.com/zabbix/7.0/alma/9/x86_64/zabbix-release-latest-7.0.el9.noarch.rpm

The 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:

bash
sudo apt install mariadb-server

AlmaLinux/Rocky:

bash
sudo dnf install mariadb-server
bash
sudo systemctl enable --now mariadb
sudo mysql_secure_installation

The 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:

bash
sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2

AlmaLinux/Rocky:

bash
sudo dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2
  • zabbix-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).
Tip: if you prefer Nginx over Apache, install zabbix-nginx-conf instead of zabbix-apache-conf, then uncomment the listen and server_name lines in /etc/zabbix/nginx.conf, filling in your own port and domain name.

Step 3. Create the database

bash
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;
EOF

Replace <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):

bash
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

The 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:

bash
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:

bash
sudo nano /etc/zabbix/zabbix_server.conf

Find the commented-out # DBPassword= line and add the same password you set in step 3 right below it:

ini
DBPassword=<password>
Important: without this line, zabbix-server won't be able to connect to the database and won't start (the error will show up in /var/log/zabbix/zabbix_server.log). The DBName=zabbix and DBUser=zabbix parameters in this file are already set by default — don't touch them, only the password.

Start the services and enable them on boot:

Ubuntu/Debian:

bash
sudo systemctl enable --now zabbix-server zabbix-agent2 apache2

AlmaLinux/Rocky:

bash
sudo systemctl enable --now zabbix-server zabbix-agent2 httpd php-fpm

Check that the server came up:

bash
sudo systemctl status zabbix-server --no-pager

The expected status is active (running). If not, check the log for the cause: sudo tail -n 30 /var/log/zabbix/zabbix_server.log.

Tip (AlmaLinux/Rocky only): if the web interface shows a "Zabbix server is not running" banner after install even though the service is active, it's usually SELinux. The zabbix-selinux-policy package from step 2 handles this in most cases; if the banner is still there, run sudo setsebool -P httpd_can_connect_zabbix on and restart httpd.

Open the ports for the web interface:

Ubuntu/Debian (ufw):

bash
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

AlmaLinux/Rocky (firewalld):

bash
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Important: if the firewall isn't set up on the server at all yet, go through the "Setting up the UFW firewall" article first — it allows SSH before enabling the firewall.

Port 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):

bash
sudo ufw allow 10051/tcp

AlmaLinux/Rocky (firewalld):

bash
sudo firewall-cmd --permanent --add-port=10051/tcp
sudo firewall-cmd --reload

Step 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:

  1. Welcome — pick the interface language, "Next".
  2. 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.
  3. Configure DB connection — Database type: MySQL; Database host: localhost; Database port — leave it at its default (with host localhost, the frontend connects via a Unix socket, no TCP involved); Database name: zabbix; User: zabbix; Password — the one you set in step 3.
  4. 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.
  5. Pre-installation summary — review it and click "Next".
  6. Install → "Finish".
  7. Log in — username Admin, password zabbix.
Important: change the password right after your first login — whether you installed Zabbix via the recipe or manually, the Admin / zabbix default is the same and widely known. At the bottom of the left-hand menu, click the user icon → Profile → the User tab → the Change password button → enter the old password (zabbix) and the new one twice → Update. Once changed, all current Admin sessions are logged out — log back in with the new password.
Done: you're logged into the web interface with the new password — the Zabbix server is set up and running.

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:

bash
sudo apt install zabbix-agent2

AlmaLinux/Rocky:

bash
sudo dnf install zabbix-agent2
Tip: instead of installing it manually on another VPS, you can use the ready-made "Zabbix agent2 linux" recipe — see the recipes section above.

Step 2. Configure the agent: Server, ServerActive, Hostname

bash
sudo nano /etc/zabbix/zabbix_agent2.conf

If 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:

ini
Server=192.0.2.10
ServerActive=192.0.2.10
Hostname=vps-01
  • 192.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:

bash
sudo systemctl restart zabbix-agent2
sudo systemctl enable zabbix-agent2
Important: on this (agent) VPS, open port 10050/tcp — this is exactly the port the Zabbix server will reach out to for data. If the firewall isn't set up yet, see the "Setting up the UFW firewall" article.

Ubuntu/Debian (ufw):

bash
sudo ufw allow 10050/tcp

AlmaLinux/Rocky (firewalld):

bash
sudo firewall-cmd --permanent --add-port=10050/tcp
sudo firewall-cmd --reload

Step 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.
  • InterfacesAgent — 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.

Done: the host is added and reporting metrics — check the data under Monitoring → Latest data, then set up triggers and notifications to fit your needs.

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.