您好,登錄后才能下訂單哦!
#!/bin/bash
#簡易安裝zabbix+LAMP
#
lamp(){
#關閉防火墻&核心安全功能
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的時區
sed -i "878cdate.timezone = PRC" /etc/php.ini
#數據庫&httpd啟動
systemctl start httpd.service
systemctl enable httpd.service
systemctl start mariadb.service
systemctl enable mariadb.service
#設定數據庫初始密碼
/usr/bin/expect <<EOF
spawn mysqladmin -u root -p password 123123
expect {
"Enter*"
{send "\r"}
}
expect eof
EOF
}
#檢測LAMP架構是否已經安裝完畢
service httpd restart &> /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數據庫和管理用戶
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 "開始準備安裝zabbix"
sleep 3
#安裝PHP對應工具
yum install php-bcmath php-mbstring -y
#生成zabbix對應yum源
rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
#安裝zabbix(網絡不好,比較難下)
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
#解決本地無法登錄問題
mysql -uroot -p123123 -e "drop user ''@localhost;"
mysql -uroot -p123123 -e "drop user ''@localhost.localdomain;"
mysql -uroot -p123123 -e "flush privileges"
#生成數據庫文件
zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -uzabbix -pzhy94666 zabbix
#修改zabbix服務端配置文件
sed -i "125cDBPassword=zhy94666" /etc/zabbix/zabbix_server.conf
#修改時區
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服務端設置完成"
fi
dizhi=`ifconfig ens33 | awk 'NR==2{print $2}'`
echo "請使用瀏覽器登陸${dizhi}/zabbix/進行安裝
默認登陸用戶名為:Admin
默認登陸密碼為:zabbix"
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。