一鍵實現基於LNMP架構的zabbix基本安裝

2021-10-02 12:08:54 字數 3585 閱讀 7576

#!/bin/bash

#簡易安裝zabbix+lnmp

#lnmp()}

expect eof

eof#安裝php 7.2

#修改fpm模組使其支援nginx

sed -i -e "8cuser = nginx"

-e "10cgroup = nginx"

/etc/php-fpm.d/www.conf

#更改nginx配置檔案使其能識別php動態檔案

sed -i "10s/index.html/index.html index.php/"

/etc/nginx/conf.d/default.conf

sed -i -e "30,36s/#//"

-e "31s/html/\/usr\/share\/nginx\/html/"

-e "34s/\/scripts/\$document_root/"

/etc/nginx/conf.d/default.conf

#配置php

sed -i -e "359s/on/off/"

-e "202s/off/on/"

/etc/php.ini

#重啟服務

systemctl start php-fpm

systemctl enable php-fpm

systemctl restart nginx

}#檢測lnmp架構是否已經安裝完畢

systemctl restart nginx &> /dev/null

service mysqld restart &> /dev/null

systemctl restart mariadb &> /dev/null

netstat -atnp | egrep '(nginx|3306)' &> /dev/null

if[ $? -ne 0 ]

;then

lnmp

fi#配置php以適應zabbix

sed -i -e "368s/30/300/"

-e "378s/60/300/"

-e "656s/8/16/"

-e "799aalways_populate_raw_post_data = -1"

-e "877cdate.timezone = asia/shanghai"

/etc/php.ini

systemctl restart php-fpm

#建立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;"

#解決本地無法登入問題

mysql -uroot -p123123 -e "drop user ''@localhost;"

mysql -uroot -p123123 -e "drop user ''@localhost.localdomain;"

mysql -uroot -p123123 -e "flush privileges"

#安裝zabbix

#生成資料庫檔案

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

#修改zabbix服務端配置檔案

sed -i -e "91s/# //"

-e "125cdbpassword=zhy94666"

/etc/zabbix/zabbix_server.conf

#提權cp

-r /usr/share/zabbix/

/usr/share/nginx/html/

chown -r zabbix:zabbix /etc/zabbix/

chown -r zabbix:zabbix /usr/share/nginx/

chown -r zabbix:zabbix /usr/lib/zabbix/

chmod -r 755 /etc/zabbix/web/

chmod -r 777 /

var/lib/php/session/

#啟動zabbix

systemctl start zabbix-server.service

systemctl enable zabbix-server.service

systemctl start zabbix-agent.service

systemctl enable zabbix-agent.service

#所有服務重啟

systemctl restart php-fpm nginx mariadb zabbix-server zabbix-agent

#檢查服務是否均啟動

test=`netstat -atnp | egrep '(nginx|3306|10051|10050)'

| grep -v "time_wait"

| wc -l`if[

$test

-ge 5 ]

;then

echo

"zabbix服務端設定完成"

fidizhi=`ifconfig ens33 | awk 'nr==2'`

echo

"請使用瀏覽器登陸$/zabbix/進行安裝

預設登陸使用者名為:admin

預設登陸密碼為:zabbix"

LNMP一鍵安裝

安裝步驟 1 使用putty或類似的ssh工具登陸vps或伺服器 登陸後執行 screen s lnmp 如果提示screen command not found 命令不存在可以執行 yum install screen 或 apt get install screen安裝,詳細內容參考screen...

LNMP一鍵安裝

系統需求 lnmp一鍵安裝包 v1.3 已經在 photonvps vultr 遨遊主機 oneasiahost新加坡vps 搬瓦工 budgetvm digitalocean locvps linode diahosting 瑞豪開源 kvmla 景文互聯 ramnode hostigation ...

一鍵安裝lnmp

系統需求 lnmp一鍵安裝包 v1.0 已經在 diahosting 感謝提供測試vps vpsyou 感謝提供測試vps photonvps 感謝提供測試vps linode vr香港vps xehost vpszz digitalocean hostigation myhost123 yardv...