LNMP自动安装脚本

1.运行前准备

>>>MySQL二进制安装脚本<<<

>>>Nginx自动编译安装脚本<<<

>>>PHP自动编译安装脚本<<<

2.脚本

#!/bin/bash
FILEPATH="/usr/local/src"
###菜单###
menu(){
title="LNMP Menu"
echo
cat <<EOF
#######################
`echo -e "\033[32;40m$title\033[0m"`
#######################
* 1)Install Nginx
* 2)Install MySQL
* 3)Install PHP
* 4)Quit
#######################
EOF
echo
}
###Usage###
Usage(){
echo $"USAGE:$0 {1|2|3|4}"
}
###Nginx文件检查###
CheckNginxFile(){
Files="nginx_auto.sh nginx_dependent.txt nginx_parameter.txt nginx.service"
for i in ${Files}
do
ls ${FILEPATH}/$i
if [[ $? != 0 ]]
then
echo "$i is not found,cancel installation"
exit 1
fi
done
}
###MySQL文件检查###
CheckMysqlFile(){
Files="mysql_auto.sh my.cnf"
for i in ${Files}
do
ls ${FILEPATH}/$i
if [[ $? != 0 ]]
then
echo "$i is not found,cancel installation"
exit 1
fi
done
}
###PHP文件检查###
CheckPhpFile(){
Files="php_auto.sh php_dependent.txt php_parameter.txt php_opcache.txt www.conf php-fpm.service"
for i in ${Files}
do
ls ${FILEPATH}/$i
if [[ $? != 0 ]]
then
echo "$i is not found,cancel installation"
exit 1
fi
done
}
clear
menu
while true
do
read -p "Input your select: " option
case $option in
1)
echo "Checking dependent files..."
CheckNginxFile
echo "Files are ready"
sh ${FILEPATH}/nginx_auto.sh
break
;;
2)
echo "Checking dependent files..."
CheckMysqlFile
echo "Files are ready"
sh ${FILEPATH}/mysql_auto.sh
break
;;
3)
echo "Checking dependent files..."
CheckPhpFile
echo "Files are ready"
sh ${FILEPATH}/php_auto.sh
break
;;
4)
break
;;
*)
Usage
;;
esac
done


「 文章如果对你有帮助,请点个赞哦^^ 」 

0

这篇文章有一条评论

评论关闭。