shell指令碼部署lnmp電商或者論壇

2021-10-18 11:58:50 字數 3290 閱讀 8550

#!/bin/bash

echo

-----------------------------

-防火牆-----------------------------------

systemctl stop firewalld #關閉防火牆

echo

"防火牆已關閉"

echo

-----------------------------

-selinux---------------------------------

-se=$(setenforce 0)

echo

$seecho

"selinux許可權已關閉"

#selinux

echo

-------------------------檢測nginx是否安裝-----------------------------

ng=nginx

rpm -qa |

| grep $ng >/dev/null

if[ $? -eq 0 ]

#if判斷nginx是否安裝

then

echo

"未安裝nginx"

echo

--------------------

-安裝nginx配置環境-------------------------

num=$(yum -y install gcc pcre-devel zlib-devel)

echo

$num >/dev/null

echo

----------------------檢測lnmp元件是否安裝--------------------

- lxy(

) lxy

echo

-----------------------

-安裝nginx------------------------------

install(

) install

else

echo

"已安裝"

fi echo

-----------------------安裝lnmp環境-----------------------------

lnmp(

) lnmp

echo

-------------------------配置nginx--------------------------------

sed -i "45s/index.html/index.php/g"

/usr/local/nginx/conf/nginx.conf

sed -i "65,71s/#//g"

/usr/local/nginx/conf/nginx.conf

sed -i "69s/scripts/\$document_root/g"

/usr/local/nginx/conf/nginx.conf

sed -i "13s/1024/10240/g"

/usr/local/nginx/conf/nginx.conf

echo

-e "<?php \n phpinfo(); \n ?>" >/usr/local/nginx/html/index.php

echo

"配置完畢"

echo

-------------------------檢測nginx埠是否占用-------------------------------

nginx=80

ps-aux | grep $nginx

if[ $? -eq 0 ]

then

echo

"埠未占用"

#判斷nginx或者httpd的服務是否啟動,防止埠占用

else

echo

"埠被占用"

kill

-9 $( netstat nlp | grep :8080)

fiecho

-----------------------檢測php-fpm是否啟動-----------------------------------

- ss -ntlp | grep php-fpm

if[ $? -eq 0 ]

then

echo

"未開啟"

else

echo

"已開啟"

systemctl stop php-fpm

fi echo

--------------------------啟動nginx環境----------------------

systemctl start php-fpm

/usr/local/nginx/sbin/nginx

# echo ---------------------------安裝電商平台----------------------

# mv tinyshopv2.5_data.zip /usr/local/nginx/html/

# cd /usr/local/nginx/html/

# unzip tinyshopv2.5_data.zip

# echo -------------------------增加許可權及重啟lnmp------------------

# chmod -r 777 /usr/local/nginx/html

# systemctl start mariadb

# /usr/local/nginx/sbin/nginx -s reload

## echo ----------------------------安裝論壇平台---------------------

# mv discuz_x3.4_sc_utf8.zip /usr/local/nginx/html

# cd /usr/local/nginx/html

# unzip discuz_x3.4_sc_utf8.zip

# echo -------------------------增加許可權及重啟lnmp------------------

# chmod -r 777 /usr/local/nginx/html

# systemctl start mariadb

# /usr/local/nginx/sbin/nginx -s reload

電商和論壇的安裝部署已注釋如有需要請取消注釋後使用

shell指令碼部署無密碼訪問

為了實現一些元件的自動化部署,可能要設定伺服器的免密訪問比較方便,最後實現了自動化部署密碼指令碼,以下為實現 邏輯。比較龐大,不能一一道出了。bin bash ips 10.100.112.79 10.100.112.203 10.100.112.204 10.100.112.205 10.100....

指令碼部署openstack

本文把openstack部署的所有命令整理成乙個完整的指令碼,乙個指令碼解決所有問題。一般部署分三步 1,安裝openstack包 2,修改配置檔案 3,執行這個指令碼。來,試一下 在python下 import mydeploy mydeploy.deploy all 如果想重置資料庫,例如nov...

shell指令碼 自動化部署lnmp

root localhost shell vim lnmp.sh bin bash yum y install httpd 安裝http yum y install mariadb mariadb devel mariadb server 安裝資料庫 yum y install php php my...