sudo apt update
sudo apt install -y curl wget vim net-tools ca-certificates gnupg lsb-release
系统更新可选,不影响主线:
sudo apt upgrade -y
查看网卡和当前网络参数:
ip addr
ip route
cat /etc/resolv.conf
本次网卡为 ens33,固定为 192.168.252.130/24,网关和 DNS 均为 192.168.252.2。
编辑 Netplan 配置文件:
sudo vim /etc/netplan/50-cloud-init.yaml
内容示例,注意 YAML 缩进必须用空格:
network:
version: 2
renderer: networkd
ethernets:
ens33:
dhcp4: no
addresses:
- 192.168.252.130/24
routes:
- to: default
via: 192.168.252.2
nameservers:
addresses: [192.168.252.2]
应用并验证:
sudo netplan try
sudo netplan apply
ip addr show ens33
ip route | grep default
ping -c 4 192.168.252.2
ping -c 4 baidu.com
resolv.conf中显示nameserver 127.0.0.53是 systemd-resolved 的正常现象,不需要手动改。
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
Ubuntu 24.04 自带 MariaDB 10.11,满足 Zabbix 7.0 要求,不需要额外配置 MariaDB 外部源。
sudo apt install -y mariadb-server nginx php8.3-fpm \
zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf \
zabbix-sql-scripts zabbix-agent
sudo systemctl enable --now mariadb
本次直接使用 sudo mysql 进入 MariaDB:
sudo mysql
在 MariaDB 提示符下执行,将 YourStrongPassword 替换为强密码:
CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'YourStrongPassword';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
SET GLOBAL log_bin_trust_function_creators = 1;
FLUSH PRIVILEGES;
EXIT;
导入 Zabbix 表结构:
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
输入 zabbix 用户密码时屏幕不显示字符,正常。导入过程几十秒到几分钟,无输出正常。
导入完成后关闭临时权限:
sudo mysql -e "SET GLOBAL log_bin_trust_function_creators = 0;"
验证表结构:
mysql -uzabbix -p -e "USE zabbix; SHOW TABLES;" | wc -l
表数量应接近 170 左右。
mysql_secure_installation为可选安全步骤,本次主线未执行;直接sudo mysql创建库也成功。
sudo vim /etc/zabbix/zabbix_server.conf
找到 DBPassword=,填入与创建 zabbix 用户时一致的密码:
DBPassword=YourStrongPassword
数据库名和用户默认已为:
DBName=zabbix
DBUser=zabbix
sudo vim /etc/php/8.3/fpm/php.ini
设置:
date.timezone = Asia/Shanghai
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
保存后重启 PHP-FPM:
sudo systemctl restart php8.3-fpm
Zabbix Web 安装向导会强制检查 PHP 时区,不设置会卡住。
/etc/nginx/conf.d/zabbix.conf 是符号链接,指向 /etc/zabbix/nginx.conf:
/etc/nginx/conf.d/zabbix.conf -> /etc/zabbix/nginx.conf
直接编辑目标文件,避免 vim 报 E166: Can't open linked file for writing:
sudo vim /etc/zabbix/nginx.conf
本次实际生效的关键配置为:
server {
listen 80;
server_name localhost;
root /usr/share/zabbix;
index index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/var/run/php/zabbix.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param DOCUMENT_ROOT /usr/share/zabbix;
fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
include fastcgi_params;
}
}
测试并重载:
sudo nginx -t
sudo systemctl reload nginx
验证本机访问:
curl -I http://127.0.0.1/
期望返回 302 Found 或 200 OK。
本次 Zabbix 前端通过根路径
/访问,因为root是/usr/share/zabbix,Nginx 会去找/usr/share/zabbix/index.php。
sudo systemctl restart zabbix-server zabbix-agent nginx php8.3-fpm
sudo systemctl enable zabbix-server zabbix-agent nginx php8.3-fpm
检查 Zabbix Server:
systemctl status zabbix-server --no-pager
本次实际状态为 active (running),子进程包括 snmp poller、agent poller、history syncer 等,说明数据库连接和表结构正常。
本次 UFW 状态为 inactive,无需放行。
如果启用了 UFW,则放行:
sudo ufw allow 80/tcp
sudo ufw allow 10050/tcp
sudo ufw allow 10051/tcp
sudo ufw reload
浏览器访问:
http://192.168.252.130/
向导中数据库连接填写:
Database host: localhost
Database name: zabbix
User: zabbix
Password: YourStrongPassword
完成后使用默认账号登录:
用户名:Admin
密码:zabbix
先安装系统中文语言包:
sudo apt update
sudo apt install -y language-pack-zh-hans language-pack-zh-hans-base
sudo locale-gen zh_CN.UTF-8
sudo update-locale
sudo systemctl restart nginx php8.3-fpm
验证:
locale -a | grep zh_CN
然后在 Zabbix 中切换:
Ctrl + F5 强制刷新浏览器缓存后重试全局默认语言可选:管理 → 常规 → GUI → Default language → Chinese (zh_CN)。
Zabbix 7.0 LTS 官方内置 Huawei VRP by SNMP 模板。后续添加华为交换机或模拟设备时:
{$SNMP_COMMUNITY} = 交换机上配置的团体名Huawei VRP by SNMP在 Zabbix 服务器上可先验证 SNMP:
sudo apt install -y snmp
snmpwalk -v 2c -c YourCommunity@123 192.168.252.200 sysDescr
能返回设备系统描述即链路正常。