Ubuntu 安装 zabbix (nginx版本)

环境

Ubuntu 18.04 安装的 zabbix 版本为 5.0,下载步骤 按照 zabbix 官网的教程,也可以根据不同的环境进行切换

安装 zabbix

安装源

[[email protected]:~]# wget https://repo.zabbix.com/zabbix/4.5/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.5-1+bionic_all.deb
--2020-03-04 17:30:54--  https://repo.zabbix.com/zabbix/4.5/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.5-1+bionic_all.deb
Resolving repo.zabbix.com (repo.zabbix.com)... 162.243.159.138, 2604:a880:1:20::b82:1001
Connecting to repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4136 (4.0K) [application/octet-stream]
Saving to: ‘zabbix-release_4.5-1+bionic_all.deb’

zabbix-release_4.5-1+bio 100%[==================================>]   4.04K  --.-KB/s    in 0s      

2020-03-04 17:30:55 (409 MB/s) - ‘zabbix-release_4.5-1+bionic_all.deb’ saved [4136/4136]

[[email protected]:~]# dpkg -i zabbix-release_4.5-1+bionic_all.deb 
Selecting previously unselected package zabbix-release.
(Reading database ... 140455 files and directories currently installed.)
Preparing to unpack zabbix-release_4.5-1+bionic_all.deb ...
Unpacking zabbix-release (1:4.5-1+bionic) ...
Setting up zabbix-release (1:4.5-1+bionic) ...

[[email protected]:~]# apt update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease [20.8 kB]
...
Fetched 7,525 kB in 3s (2,359 kB/s)                     
Reading package lists... Done
Building dependency tree       
Reading state information... Done
27 packages can be upgraded. Run 'apt list --upgradable' to see them.

安装zabbix server,前端,代理

[[email protected]:~]# apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-agent
Reading package lists... Done
Building dependency tree       
Reading state information... Done
...

创建数据库、授权等

mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to [email protected] identified by 'password';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit;
Bye

导入数据库表结构

[[email protected]:/]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: 

配置zabbix

改DB配置

[[email protected]:/]# vim /etc/zabbix/zabbix_server.conf 

DBPassword 改成 DBPassword=password

配置zabbix前端

[[email protected]:/]# vim /etc/zabbix/nginx.conf 

server_name 和 端口号相关的改成自己想要的配置

启动Zabbix server和agent进程

启动Zabbix server和agent进程,并为它们设置开机自启:

[[email protected]:/]# systemctl restart zabbix-server zabbix-agent nginx php7.2-fpm
[[email protected]:/]# systemctl enable zabbix-server zabbix-agent nginx php7.2-fpm
Synchronizing state of zabbix-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable zabbix-server
Synchronizing state of zabbix-agent.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable zabbix-agent
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx
Synchronizing state of php7.2-fpm.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable php7.2-fpm

测试访问

打开网站

根据以下教程一步一步检查设置等信息进行相对应的调整
https://www.zabbix.com/documentation/5.0/manual/installation/install#installing_frontend

最后systemctl enable zabbix-server和agent,zabbix-server可能需要重启机器才能启动

/* 在途中遇到很多错误排查,后续会更新出来

参考

Responses