Ubuntu 安装 zabbix (nginx版本)

环境

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

安装 zabbix

安装源

[root@Ubuntu:~]# 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]

[root@Ubuntu:~]# 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) ...

[root@Ubuntu:~]# 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,前端,代理

[root@Ubuntu:~]# 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 zabbix@localhost identified by 'password';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit;
Bye

导入数据库表结构

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

配置zabbix

改DB配置

[root@Ubuntu:/]# vim /etc/zabbix/zabbix_server.conf 

DBPassword 改成 DBPassword=password

配置zabbix前端

[root@Ubuntu:/]# vim /etc/zabbix/nginx.conf 

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

启动Zabbix server和agent进程

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

[root@Ubuntu:/]# systemctl restart zabbix-server zabbix-agent nginx php7.2-fpm
[root@Ubuntu:/]# 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
  1. Hey There. I discovered your blog using msn. That is a very smartly written article. I will make sure to bookmark it and come back to learn extra of your helpful info. Thank you for the post. I'll definitely return.

    Reply
  2. What's up i am kavin, its my first occasion to commenting anyplace, when i read this paragraph i thought i could also make comment due to this brilliant piece of writing.

    Reply
  3. I love what you guys are usually up too. This type of clever work and exposure! Keep up the awesome works guys I've added you guys to our blogroll.

    Reply
  4. Do you mind if I quote a few of your posts as long as I provide credit and sources back to your weblog? My blog site is in the very same area of interest as yours and my users would really benefit from a lot of the information you provide here. Please let me know if this okay with you. Thank you!

    Reply
  5. There is certainly a lot to know about this issue. I love all the points you've made.

    Reply
  6. Neat blog! Is your theme custom made or did you download it from somewhere? A design like yours with a few simple tweeks would really make my blog shine. Please let me know where you got your design. Cheers

    Reply