Install Zabbix Monitoring on VPS Ubuntu
Zabbix is an enterprise-grade monitoring platform that is free to use. It monitors CPU, RAM, disk I/O, network bandwidth, and processes across multiple hosts simultaneously. You can set up alerts to notify you via email, Line, or Telegram when server metrics exceed defined thresholds. Zabbix is ideal for administrators managing multiple servers who need centralized monitoring capabilities.
System Requirements
Zabbix Server requires at least 2GB of RAM and 2 CPU cores for small monitoring deployments. A 4GB RAM VPS is suitable for monitoring 20-50 hosts.
Install Zabbix 7 on Ubuntu 22.04
# Add Zabbix repository
wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-1+ubuntu22.04_all.deb
sudo dpkg -i zabbix-release_7.0-1+ubuntu22.04_all.deb
sudo apt update
# Install Zabbix server + frontend + agent
sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent -y
# Install MariaDB
sudo apt install mariadb-server -y
sudo systemctl enable --now mariadb
Create Database for Zabbix
sudo mysql -u root -p
CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER zabbix@localhost IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost;
SET GLOBAL log_bin_trust_function_creators = 1;
FLUSH PRIVILEGES;
EXIT;
# Import schema
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -u zabbix -p zabbix
# Disable log_bin_trust_function_creators after import
sudo mysql -u root -p
SET GLOBAL log_bin_trust_function_creators = 0;
EXIT;
Configure Zabbix Server
sudo nano /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=StrongPassword123!
Set Up Nginx for Zabbix Frontend
sudo nano /etc/zabbix/nginx.conf
server {
listen 8080;
server_name _;
root /usr/share/zabbix;
# ... (Zabbix will configure most settings automatically)
}
sudo systemctl enable --now zabbix-server zabbix-agent nginx php8.1-fpm
sudo systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm
Open your browser and navigate to http://YOUR-VPS-IP:8080 then follow the setup wizard. For the first login, use user: Admin / password: zabbix
Install Zabbix Agent on Monitored Hosts
# On the server you want to monitor
wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-1+ubuntu22.04_all.deb
sudo dpkg -i zabbix-release_7.0-1+ubuntu22.04_all.deb
sudo apt update && sudo apt install zabbix-agent -y
sudo nano /etc/zabbix/zabbix_agentd.conf
# Change Server= to the IP of your Zabbix Server
Server=YOUR-ZABBIX-SERVER-IP
ServerActive=YOUR-ZABBIX-SERVER-IP
Hostname=myserver01
sudo systemctl enable --now zabbix-agent
Verify Zabbix is Working Correctly
# Check Zabbix server
sudo systemctl status zabbix-server
sudo tail -f /var/log/zabbix/zabbix_server.log
# Check agent
sudo systemctl status zabbix-agent
sudo tail -f /var/log/zabbix/zabbix_agentd.log
# Test agent connectivity from server
zabbix_get -s 127.0.0.1 -p 10050 -k "system.uptime"
zabbix_get -s AGENT-IP -p 10050 -k "agent.ping"
zabbix_get is a testing tool that verifies connectivity between server and agent. If you receive a response value, it means the agent is responding normally.
Common Issues & Troubleshooting
Error: "Cannot connect to the database"
Check the password in zabbix_server.conf and MySQL user permissions:
mysql -u zabbix -p zabbix
# If login succeeds, the credentials are correct
sudo systemctl restart zabbix-server
sudo tail -20 /var/log/zabbix/zabbix_server.log
Agent Not Responding (ZBX_NOTSUPPORTED)
Check firewall settings and port 10050:
sudo ufw allow from ZABBIX-SERVER-IP to any port 10050
sudo ss -tulnp | grep 10050
# Test from Zabbix server
telnet AGENT-IP 10050
Frontend Shows PHP Timezone Error
Set timezone in PHP configuration:
sudo nano /etc/php/8.1/fpm/php.ini
# Find the date.timezone line and change it to:
date.timezone = Asia/Bangkok
sudo systemctl restart php8.1-fpm
Zabbix Server Stops When Database is Slow
Increase timeout and worker threads in the configuration:
sudo nano /etc/zabbix/zabbix_server.conf
StartPollers=10
StartPollersUnreachable=2
Timeout=30
sudo systemctl restart zabbix-server
Frequently Asked Questions
How does Zabbix differ from Grafana + Prometheus?
Zabbix is an all-in-one solution with built-in data collection, alerting, and dashboarding. Grafana + Prometheus require setting up multiple components separately. Zabbix is better suited for large infrastructure monitoring that requires SNMP and network device monitoring, which is more challenging with Prometheus.
Can Zabbix send alerts to Line?
Yes, through Zabbix Media Type configured as a webhook pointing to Line Notify API or Line Messaging API. Set this up in Administration > Media Types > Create New Webhook and define the URL and message template.
How many servers can a single Zabbix instance monitor?
A Zabbix server on a 4GB RAM VPS can monitor approximately 50-100 hosts without issues. For larger deployments, upgrade your RAM and use distributed monitoring through Zabbix Proxy.