安装环境

  • centos7.9系统
  • 使用root权限登录到CentOS 7服务器。
  • 确保服务器可以访问互联网


# 关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service


# 禁用SELINUX

setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config


# 安装Zabbix源并修改为阿里云源

cd /etc/yum.repos.d/
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sed -i.bak 's#repo.zabbix.com#mirrors.aliyun.com/zabbix#' zabbix.repo
sed -i 's#enabled=0#enabled=1#' zabbix.repo
yum clean all


# 安装Zabbix

yum -y install zabbix-server-mysql zabbix-agent
yum -y install centos-release-scl
yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl


# 安装并启动MariaDB数据库

yum -y install mariadb mariadb-server
systemctl start mariadb.service


# 创建数据库并授权

mysql -e 'create database zabbix character set utf8 collate utf8_bin;'
mysql -e 'create user zabbix@localhost identified by "zabbix"' 
mysql -e 'grant all privileges on zabbix.* to zabbix@localhost;'
mysql -e 'flush privileges;'


# 导入Zabbix数据库

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix -Dzabbix



# 配置Zabbix server数据库密码

sed -i.bak '/^# DBPassword=*/i DBPassword=zabbix' /etc/zabbix/zabbix_server.conf


# 添加时区

sed -i.bak '/^; php_value[date.timezone]*/i php_value[date.timezone] = Asia/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf


# 解决中文乱码

yum -y install wqy-microhei-fonts
\cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf


# 开机自启动

systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm


# 输出信息

输入http://ip地址/zabbix"访问zabbix