centos7脚本部署zabbix server(单机lamp)

#!/bin/bash

rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
cp /etc/yum.repos.d/zabbix.repo{,.bak}
sed -i.bak 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#g' /etc/yum.repos.d/zabbix.repo
yum clean all

yum install -y mariadb-server zabbix-server-mysql zabbix-agent zabbix-get centos-release-scl

sed -i.bak -e 's#http://buildlogs.centos.org#https://mirrors.aliyun.com/#g' \
-e 's#http://vault.centos.org#https://mirrors.aliyun.com/#g'\
-e 's#http://debuginfo.centos.org#https://mirrors.aliyun.com/#g'\
-e 's/^enabled=0/enabled=1/' /etc/yum.repos.d/zabbix.repo
yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl

systemctl enable --now mariadb

cat > zabbix.sql <<-EOF
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'password';
grant all privileges on zabbix.* to zabbix@localhost;
EOF

mysql < zabbix.sql

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -ppassword zabbix
sed -i.bak '/^# DBPassword/c DBPassword=password' /etc/zabbix/zabbix_server.conf
sed -i.bak '/php_value\[date.timezone\]/c php_value[date.timezone] = Asia/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

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

ss -tnl

posted @ 2022-07-06 12:42  joechenyao  阅读(71)  评论(0)    收藏  举报