#!/bin/bash
#簡(jiǎn)易安裝zabbix+LAMP
#
lamp(){
#關(guān)閉防火墻&核心安全功能
systemctl stop firewalld.service
systemctl disable firewalld.service &> /dev/null
setenforce 0
sed -i "7cSELINUX=disabled" /etc/sysconfig/selinux
yum install -y \
httpd \
mariadb-server mariadb \
php \
php-MySQL \
php-gd \
libjpeg* \
php-ldap \
php-odbc \
php-pear \
php-xml \
php-xmlrpc \
php-mhash \
expect
#修改httpd的配置文件
sed -i -e "95aServerName www.kgc.com" -e "/DirectoryIndex/s/index.html/index.html index.php/" /etc/httpd/conf/httpd.conf
#修改PHP的時(shí)區(qū)
sed -i "878cdate.timezone = PRC" /etc/php.ini
#數(shù)據(jù)庫(kù)&httpd啟動(dòng)
systemctl start httpd.service
systemctl enable httpd.service
systemctl start mariadb.service
systemctl enable mariadb.service
#設(shè)定數(shù)據(jù)庫(kù)初始密碼
/usr/bin/expect < /dev/null
service mysqld restart &> /dev/null
systemctl restart mariadb &> /dev/null
netstat -atnp | egrep '(httpd|3306)' &> /dev/null
if [ $? -ne 0 ];then
lamp
fi
#建立zabbix數(shù)據(jù)庫(kù)和管理用戶
mysql -uroot -p123123 -e "CREATE DATABASE zabbix character set utf8 collate utf8_bin;"
mysql -uroot -p123123 -e "GRANT all privileges ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'zhy94666';"
mysql -uroot -p123123 -e "flush privileges;"
echo "開(kāi)始準(zhǔn)備安裝zabbix"
sleep 3
#安裝PHP對(duì)應(yīng)工具
yum install php-bcmath php-mbstring -y
#生成zabbix對(duì)應(yīng)yum源
rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
#安裝zabbix(網(wǎng)絡(luò)不好,比較難下)
for ((i=1;i>0;i++));do
rpm -q zabbix-web-mysql &> /dev/null
if [ $? -ne 0 ];then
yum install zabbix-server-mysql zabbix-web-mysql -y
else
break
fi
done
#解決本地?zé)o法登錄問(wèn)題
mysql -uroot -p123123 -e "drop user ''@localhost;"
mysql -uroot -p123123 -e "drop user ''@localhost.localdomain;"
mysql -uroot -p123123 -e "flush privileges"
#生成數(shù)據(jù)庫(kù)文件
zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -uzabbix -pzhy94666 zabbix
#修改zabbix服務(wù)端配置文件
sed -i "125cDBPassword=zhy94666" /etc/zabbix/zabbix_server.conf
#修改時(shí)區(qū)
sed -i "20cphp_value date.timezone Asia/Shanghai" /etc/httpd/conf.d/zabbix.conf
systemctl enable zabbix-server
systemctl start zabbix-server
service httpd restart
netstat -anpt | grep zabbix &> /dev/null
if [ $? -eq 0 ];then
echo "zabbix服務(wù)端設(shè)置完成"
fi
dizhi=`ifconfig ens33 | awk 'NR==2{print $2}'`
echo "請(qǐng)使用瀏覽器登陸${dizhi}/zabbix/進(jìn)行安裝
默認(rèn)登陸用戶名為:Admin
默認(rèn)登陸密碼為:zabbix"
本文題目:一鍵實(shí)現(xiàn)基于LAMP架構(gòu)的zabbix基本安裝
網(wǎng)站鏈接:
http://weahome.cn/article/psgdph.html