If you have been meaning to stand up a self-hosted monitoring server and keep deferring it, this is the whole path in one sitting: a Zabbix 7.0 LTS server with a PostgreSQL (or MySQL) backend, the nginx frontend, and a fleet of hosts running Zabbix Agent 2 in active mode so nothing needs an inbound firewall hole. By the end you will have new VMs that enrol themselves, a template collecting data, one trigger that fires, and one action that sends the notification. The single decision that trips most people up — active versus passive checks — gets settled early, because getting it wrong means a host list full of red icons and no data.
What you’ll accomplish
- A Zabbix 7.0 LTS server running against PostgreSQL 16 (MySQL 8 variant included) with the schema imported and the frontend served by nginx and PHP-FPM.
- Agent 2 installed on a host, talking to the server over active checks only — outbound TCP 10051, no listener exposed.
- PSK encryption on the agent-to-server link, so a stolen network position does not become free metric injection.
- An auto-registration action so a freshly built VM appears in the right host group with the right template linked, without anyone opening the UI.
- One trigger and one alert action, verified end to end by deliberately breaking something.
Prerequisites
- A Linux host for the server. Commands below are for Ubuntu 24.04 LTS; RHEL 9 and Debian 12 packages exist in the same repository and differ only in the package manager and the PHP package names. Two vCPU and 4 GB RAM is a sane starting point for a few dozen hosts.
- Root or
sudo, and outbound HTTPS from the server to reachrepo.zabbix.com. - PostgreSQL 13 or newer, or MySQL 8.0 / MariaDB 10.5 or newer. Zabbix 7.0 dropped support for older majors. The database can be local or remote; local is assumed here.
- The monitored hosts need outbound TCP 10051 to the server. They do not need inbound anything. That is the point of active mode.
- A DNS name or a stable IP for the server. Agents are configured with it, so changing it later means touching every agent.
How it works
Zabbix has four moving parts and one non-obvious detail about who connects to whom.
The server process holds the configuration in memory, accepts connections, evaluates trigger expressions, and writes history to the database. The database holds everything: configuration, history, trends, events. The frontend is a PHP application behind nginx that reads and writes that same database directly — it is not a client of the server process for normal work, which is why a broken frontend and a broken server are separate problems. The agent runs on each monitored host.
The part people get wrong is direction. In the default passive mode, the server’s poller processes open a connection to the agent on TCP 10050. Behind NAT, a cloud security group, or any host firewall with a default-deny inbound policy, that connection never arrives. In active mode the agent opens the connection to the server on TCP 10051, asks for its list of checks, and pushes results back over the same outbound path.
Active mode also scales better: the server stops maintaining a poller loop against every host and instead accepts batched results. For an agent fleet, active is the default you should choose.
Step-by-step
1. Add the Zabbix 7.0 repository. The release package name carries a revision suffix that increments; check the current filename on the Zabbix download page rather than assuming.
cd /tmp
wget https://repo.zabbix.com/zabbix/7.0/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-2+ubuntu24.04_all.deb
sudo dpkg -i zabbix-release_7.0-2+ubuntu24.04_all.deb
sudo apt update
Success looks like the Zabbix repo appearing in the update output:
Get:5 https://repo.zabbix.com/zabbix/7.0/release/ubuntu noble InRelease
2. Install the server, frontend, and SQL scripts. For PostgreSQL:
sudo apt install -y zabbix-server-pgsql zabbix-frontend-php \
php8.3-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent2
For MySQL, swap the first and third packages for zabbix-server-mysql and php8.3-mysql. Everything after this point is identical apart from the schema import.
3. Create the database and import the schema. PostgreSQL:
sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix -E UTF8 -T template0 zabbix
Locate the schema file rather than guessing — the path moved between majors:
dpkg -L zabbix-sql-scripts | grep 'postgresql/server.sql.gz'
/usr/share/zabbix/sql-scripts/postgresql/server.sql.gz
Then import it. This takes a minute or two and prints a long stream of CREATE TABLE lines:
zcat /usr/share/zabbix/sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
For MySQL, create the database with utf8mb4 and the utf8mb4_bin collation, temporarily allow function creation, import, then turn it back off:
CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'choose-a-strong-password';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
SET GLOBAL log_bin_trust_function_creators = 1;
Then import the MySQL schema and put that setting back:
zcat /usr/share/zabbix/sql-scripts/mysql/server.sql.gz \
| mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
SET GLOBAL log_bin_trust_function_creators = 0;
Leaving it at 1 weakens a binary-logging safety check for every database on the instance, so do not skip the reset.
Confirm the import landed:
sudo -u zabbix psql -d zabbix -c "SELECT count(*) FROM information_schema.tables WHERE table_schema='public';"
count
-------
173
(1 row)
The exact count varies by point release; anything in the 170s means the schema is in.
4. Configure the server. Edit /etc/zabbix/zabbix_server.conf. The lines that matter for a first run:
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=choose-a-strong-password
ListenPort=10051
LogFile=/var/log/zabbix/zabbix_server.log
CacheSize=64M
HistoryCacheSize=32M
ValueCacheSize=64M
StartTrappers=10
StartPreprocessors=4
Timeout=4
StartTrappers is the one to raise as the agent fleet grows — trappers are the processes that accept incoming active-agent connections. StartPollers matters only if you also run passive checks; leave it at the default when you do not. Start the server:
sudo systemctl enable --now zabbix-server
sudo tail -n 5 /var/log/zabbix/zabbix_server.log
1234:20260804:101201.412 Starting Zabbix Server. Zabbix 7.0.11 (revision abc1234).
1234:20260804:101201.418 ****** Enabled features ******
1234:20260804:101201.501 server #0 started [main process]
5. Bring up the nginx frontend. The package ships /etc/zabbix/nginx.conf with the listener commented out. Uncomment and set the two lines:
listen 8080;
server_name zabbix.example.com;
Then restart and enable:
sudo systemctl restart zabbix-server zabbix-agent2 nginx php8.3-fpm
sudo systemctl enable zabbix-server zabbix-agent2 nginx php8.3-fpm
curl -s -o /dev/null -w '%{http_code}\n' http://localhost:8080/
200
Open http://zabbix.example.com:8080/ and walk the setup wizard — it checks PHP settings, asks for the database credentials, and writes /etc/zabbix/web/zabbix.conf.php. Log in as Admin with the password zabbix, then change it immediately under Users → Users → Admin. Put a real TLS certificate in front of this before it sees production traffic.
6. Install and configure Agent 2 on a monitored host. Add the same repository on the host, then:
sudo apt install -y zabbix-agent2
Edit /etc/zabbix/zabbix_agent2.conf:
Server=10.20.0.5
ServerActive=10.20.0.5
Hostname=web-01
RefreshActiveChecks=2m
BufferSend=5
BufferSize=100
HostMetadata=linux-prod
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ServerActive is what enables active checks — it is the address the agent dials out to. Server is the allow-list for incoming passive connections; keep it set so zabbix_get works for debugging, or leave it empty if you want the agent to refuse inbound entirely. Hostname must match the host’s technical name in the frontend exactly, character for character, or active checks return nothing. HostMetadata is the free-form string the auto-registration action will match on.
7. Turn on PSK encryption. Generate a 256-bit key on the host:
sudo openssl rand -hex 32 | sudo tee /etc/zabbix/zabbix_agent2.psk > /dev/null
sudo chown zabbix:zabbix /etc/zabbix/zabbix_agent2.psk
sudo chmod 600 /etc/zabbix/zabbix_agent2.psk
Append to the agent config:
TLSConnect=psk
TLSAccept=psk
TLSPSKIdentity=PSK autoregistration
TLSPSKFile=/etc/zabbix/zabbix_agent2.psk
TLSConnect governs outbound (active checks and auto-registration); TLSAccept governs what inbound connections are allowed. Setting both to psk means the agent will neither send nor accept anything in the clear.
On the server side, PSK is not configured in zabbix_server.conf — it lives per host in the frontend, and for auto-registration under Administration → General → Autoregistration. Set encryption there to PSK, use the identity PSK autoregistration, and paste the key value. Every agent that should self-enrol shares this one key, so treat it as a bootstrap secret and rotate per-host keys afterwards for anything sensitive.
8. Create the auto-registration action. Go to Alerts → Actions → Autoregistration actions → Create action. Name it Enrol Linux hosts. Under Conditions, add: Host metadata — contains — linux-prod. Under Operations, add three:
- Add host
- Add to host group:
Linux servers - Link template:
Linux by Zabbix agent active
That template name is load-bearing. Linking the plain Linux by Zabbix agent template to an agent that only does active checks gives you a host full of items that never collect anything. Enable the action and start the agent:
sudo systemctl enable --now zabbix-agent2
sudo grep -E 'Starting Zabbix Agent|hostname' /var/log/zabbix/zabbix_agent2.log
Starting Zabbix Agent 2 [web-01]. (7.0.11)
Zabbix Agent2 hostname: [web-01]
Within a couple of minutes, web-01 appears under Data collection → Hosts.
9. Add a trigger and an alert action. On the host, go to Triggers → Create trigger:
- Name:
No data from agent on {HOST.NAME} - Severity:
High - Expression:
nodata(/web-01/agent.ping,3m)=1
Then Alerts → Actions → Trigger actions → Create action. Condition: Trigger severity — is greater than or equals — High. Operation: Send message to user groups — Zabbix administrators — via Email. The email media type itself is configured under Alerts → Media types → Email, and the receiving user needs an address in Users → Users → (user) → Media. Missing that last piece is the most common reason an action shows as executed while no mail ever leaves.
Validate it works
Confirm the server is accepting agent connections:
sudo ss -lntp | grep 10051
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:* users:(("zabbix_server",pid=1234,fd=5))
From the server, prove the agent responds. Install the client and drop a copy of the same key somewhere root can read it — note that zabbix_get is a passive tool, so this checks reachability and PSK, not active checks:
sudo apt install -y zabbix-get
sudo install -m 600 /dev/stdin /root/probe.psk <<< 'PASTE_THE_SAME_HEX_KEY'
zabbix_get -s 10.20.0.31 -k agent.ping \
--tls-connect psk \
--tls-psk-identity 'PSK autoregistration' \
--tls-psk-file /root/probe.psk
1
Prove active checks specifically by looking for values landing in the database in the last five minutes:
sudo -u zabbix psql -d zabbix -c \
"SELECT count(*) FROM history_uint WHERE clock > extract(epoch from now())::int - 300;"
A count climbing between runs means data is flowing. In the UI, Monitoring → Latest data filtered to the host shows timestamps advancing.
Now fire the trigger on purpose:
sudo systemctl stop zabbix-agent2
After three minutes, Monitoring → Problems shows No data from agent on web-01 at High severity, and Reports → Action log shows the notification with its delivery status. Start the agent again and confirm the problem resolves on its own.
Troubleshooting
- Host shows a red ZBX icon but the graphs are full. The host is unreachable for passive checks while active checks work fine. Either you linked a passive template, or an item was created with type Zabbix agent instead of Zabbix agent (active). Swap the template to the
... by Zabbix agent activevariant. The red icon is not a data problem. - Agent log repeats
active check configuration update from host [...] started to fail. Nearly always a name mismatch: the agent’sHostnamedoes not equal the host’s technical name in the frontend. It is case-sensitive and whitespace-sensitive. Fix one side, restart the agent, and the message stops within oneRefreshActiveCheckscycle. - Auto-registration never fires. Three usual causes: the action is disabled,
HostMetadatadoes not satisfy the condition, or a host with that name already exists — auto-registration only creates unknown hosts. Delete the stale host or change the agent’sHostname. Also check that the auto-registration PSK identity on the agent matches the one in Administration → General → Autoregistration; a mismatch is refused before the action is ever evaluated. connection of type "unencrypted" is not allowed. The server host entry expects PSK but the agent is still sending in the clear, or vice versa. Line upTLSConnect/TLSAccepton the agent with the host’s Encryption tab. Also confirm the PSK file is readable by thezabbixuser and holds at least 32 hex characters.- History tables grow without bound and the housekeeper falls behind. Zabbix’s built-in housekeeper deletes row by row and does not keep up past a few hundred hosts. Shorten history retention on the templates, then move to TimescaleDB partitioning (PostgreSQL) or native partitioning (MySQL) and disable housekeeping for history and trends.
When this is the wrong approach
Zabbix’s model is host-centric: a thing exists, it has items, items have thresholds. That fits VMs, network gear, and appliances that live for months. It fits containers poorly.
- Short-lived and dynamically scheduled workloads. If your compute is pods that live for twenty minutes, a pull-based system with service discovery is a better match — see installing Prometheus on Ubuntu and routing alerts with Alertmanager.
- High-cardinality, label-oriented analysis. Zabbix trigger expressions are fine for thresholds on known items. They are not PromQL, and slicing one metric across a dozen dimensions is awkward.
- You already run a Prometheus fleet. Two agent fleets on the same hosts is double the config drift for one set of graphs. Pick one collection path.
- You do not want to own a database. The history tables are the operational cost of Zabbix, and they never stop growing on their own. If nobody will own partitioning and backups, a hosted service is the honest answer.
- Dashboards are the real requirement. If the goal is nice graphs rather than alerting, point Grafana at whatever backend you already have instead of adding a monitoring server.
The Zabbix 7.0 manual is the reference for item keys, trigger functions, and template internals.
If alerts fire into an empty room after hours, that’s exactly what 24/7 Monitoring & Response closes — book a monitoring and response review.