### 1、准备zabbix5.0 repository文件
编辑/etc/yum.repos.d/zabbix.repo,添加以下内容:
```shell

[zabbix]
name=zabbix
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/$releasever/$basearch/
enabled=1
gpgcheck=0
[zabbix-frontend]
name=zabbix-frontend
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/$releasever/$basearch/frontend/
enabled=1
gpgcheck=0
```
### 2、安装Zabbix server和agent
```shell
yum install -y zabbix-server-mysql zabbix-agent
```
### 3、安装Zabbix前端页面
当前zabbix frontend须要PHP 7.2或更高版本,但默认情形下RHEL/CentOS 7供应PHP 5.4版本,须要手动升级版本至PHP 7.2或更高版本。
#### 3.1 安装[Red Hat Software Collections](https://access.redhat.com/documentation/en-us/red_hat_software_collections/3/)
Red Hat Software Collections中包含高版本PHP
```shell
yum install -y centos-release-scl
```
查看php 7.x版本
```shell
yum list rh-php7\
```
#### 3.2 安装zabbix frontend
```shell
yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl
```
### 4、安装MySQL 5.7
#### 4.1 安装mysql80-community-release-el7-3.noarch.rpm
```shell
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
```
#### 4.2 开启要安装版本的仓库
```shell
yum install -y yum-utils
yum-config-manager --enable mysql57-community
yum-config-manager --disable mysql80-community
```
#### 4.3 安装MySQL-server和MySQL开拓工具
```shell
yum install -y mysql-community-server mysql++-devel
```
#### 4.4 创建干系目录并修正属主、属组为mysql用户
```shell
mkdir -p /data/mysql
mkdir -p /var/log/mysql
chown -R mysql.mysql /data/mysql
chown -R mysql.mysql /var/log/mysql
```
#### 4.5 修正配置文件
数据目录及socket文件目录修正为/data/mysql目录,删除/etc/my.cnf中原内容,填入以下内容:
```ini
[mysqld]
symbolic-links=0
datadir=/data/mysql
socket=/data/mysql/mysql.sock
log-error=/var/log/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid
[client]
socket=/data/mysql/mysql.sock
```
#### 4.5 启动做事
```shell
systemctl start mysqld
systemctl enable mysqld
```
#### 4.6 修正root密码
查看临时密码:
```shell
grep 'temporary password' /var/log/mysql/mysqld.log
```
上岸mysql:
```shell
mysql -uroot -hlocalhost -p'temporary password'
```
修正密码:(MySQL默认密码策略为包含数字、大、小写字母 、分外字符、长度至少8位)
```shell
ALTER USER 'root'@'localhost' IDENTIFIED BY 'mM:zZ;Wt9w5!UwtS';
quit;
```
### 5、为zabbix建用户、建库
```shell
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'Zabbix-Server1';
grant all privileges on zabbix. to zabbix@localhost;
quit;
```
### 6、创建初始化库
```shell
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:Zabbix-Server1
```
### 7、做事配置
#### 7.1 为Zabbix Server配置数据库
编辑/etc/zabbix/zabbix_server.conf,修正DBPassword的值为数据库zabbix用户的密码
```ini
DBPassword=Zabbix-Server1
```
#### 7.2 配置php时区
编辑/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf,修正如下内容:
```ini
php_value[date.timezone] = Asia/Shanghai
```
### 8、启动Zabbix Server、agent等程序
```shell
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
```
### 9、访问web页面
浏览器输入http://zabbix-server-ip/zabbix进行页面设置:
Next step(Welcome toZabbix 5.0) --> Next step (Check of pre-requisites) --> Configure DB connection(输入数据库信息) --> Next step (Zabbix server details) --> Next step (Pre-installation summary) --> Next step (Install) --> Finish