系统为centos7.2
(zabbix需要LAMP或LNMP环境,此篇为LAMP环境)
- 首先添加阿里云镜像
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
2.安装epel源
yum install epel-release
(之前安装过,所以Nothing to do)
3.增加zabbix源
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
(之前下载过)
4.关闭selinux、firewalld、iptables
5.安装php-fpm和mariadb
yum -y install php-fpm mariadb mariadb-server
6.安装zabbix(zabbix-server-mysql、zabbix-web-mysql、zabbix-agent)
这三个不可一起安装,要单独安装,不然会报错(具体原因我也不懂为什么,手动笑哭)
yum install zabbix-server-mysql
yum install zabbix-web-mysql
yum install zabbix-agent
7.启动mariadb
systemctl enable mariadb
systemctl start mariadb
8.配置mariadb
初始化mariadb
mysql_secure_installation
(输入root密码时直接enter)
分别是(1)为root用户设置密码
(2)删除匿名账号
(3)取消root用户远程登陆
(4)删除test库和对test库的访问权限
(5)刷新授权表使修改生效
9.创建zabbix数据库及访问用户
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix@jz';
10.导入zabbix数据结构
(查找create.sql文件位置)
zcat /usr/share/doc/zabbix-server-mysql-4.0.10/create.sql.gz | mysql -uzabbix -pzabbix@jz zabbix
11.修改zabbix-server配置文件
vim /etc/zabbix/zabbix_server.conf
//修改的内容如下
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix@jz
12.修改http配置文件,修改时区为亚洲上海
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
13.启动相关应用服务并设置开机启动
systemctl enable php-fpm
systemctl start php-fpm
systemctl enable httpd
systemctl start httpd
systemctl enable zabbix-server
systemctl start zabbix-server
systemctl enable zabbix-agent
systemctl start zabbix-agent
14.在web页面访问zabbix-server的ip地址加zabbix
(用户名Admin,密码zabbix)
(配置成功!)