lnmp菜单

时间秒杀一切 提交于 2020-02-03 17:17:16

粗略写写 

 

 

 

 

 #!/bin/bash
 echo  "                欢迎使用LNMP辅助工具    "

       echo -e "\e[1;33m------------------------------------------------------\e[0m"

       echo "      1)部署nginx并开启"

       echo "      2)修改nginx.conf,准备index.php测试页面"

       echo "      3)部署mysql并开启"

       echo "      4)部署php并开启"
 
       echo "      5)一件部署全部并开启"

     echo "      0)退出"

     
      echo -e "\e[1;33m------------------------------------------------------\e[0m"
echo -e "\e[1;33m请输入您的选择\e[0m"
read  -p " " choice

case $choice in
1)
systemctl stop firewalld
#拉取nginx安装包,也可以自己在当前目录下准备安装包--------------------------------------------------------
#wget http://nginx.org/download/nginx-1.16.1.tar.gz

#解压nginx安装包
tar zxf nginx-1.16.1.tar.gz

#下载相关依赖包
yum -y install gcc pcre-devel zlib-devel

#编译安装
cd nginx-1.16.1 && ./configure && make && make install

#启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx -s reload


ss -ntlp | grep nginx
if [ $? -eq 0 ];then
        echo -e "\e[1;33mnginx已成功开启\e[0m"
        exit
fi
;;




2)
#准备好测试页面
echo "<?php phpinfo(); ?>" > /usr/local/nginx/html/index.php
#需要自己主备好修改后的配置文件nginx.conf
cp nginx.conf /usr/local/nginx/conf/nginx.conf
echo -e "\e[1;33m完毕\e[0m"
;;



3)
#开始下载MySQL------------------------------------------------------------------------------------------------
yum -y install mariadb mariadb-server

#开启mysql
systemctl start mariadb

#查看是否开启
ss -ntl | grep 3306

if [ $? -eq 0 ];then
        echo -e "\e[1;33mmysql已成功开启\e[0m"
        exit
fi
;;





4)
#开启下载php系列---------------------------------------------------------------------------------------------------
yum -y install php php-gd php-mysql php-fpm

#开启php-fpm
systemctl start php-fpm

#查看php-fpm是否开启
ss -ntlp | grep php-fpm

if [ $? -eq 0 ];then
        echo -e "\e[1;33mphp-fpm已成功开启\e[0m"
        exit
fi
;;






5)
echo -e "\e开始nginx部分安装并开启-------------------------------------------------------------------------------------------\e[0m"
#拉取nginx安装包,也可以自己在当前目录下准备安装包--------------------------------------------------------
#wget http://nginx.org/download/nginx-1.16.1.tar.gz

#解压nginx安装包
tar zxf nginx-1.16.1.tar.gz

#下载相关依赖包
yum -y install gcc pcre-devel zlib-devel

#编译安装
cd nginx-1.16.1 && ./configure && make && make install

#启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx -s reload
echo -e "\e[1;33mnginx已开启\e[0m"



echo -e "\e[1;33m开始mysql部分-------------------------------------------------------------------------------------------\e[0m"
#开始下载MySQL------------------------------------------------------------------------------------------------
yum -y install mariadb mariadb-server

#开启mysql
systemctl start mariadb
echo -e "\e[1;33mmysql已开启\e[0m"



echo -e "\e[1;33m开始php部分并开启php-fpm-------------------------------------------------------------------------------------------\e[0m"
#开启下载php系列
yum -y install php php-gd php-mysql php-fpm

#开启php-fpm
systemctl start php-fpm
echo -e "\e[1;33mphp-fpm已开启\e[0m"
echo -e "\e[1;33mLNMP已部署完毕!!!\e[0m"
;;

0)
echo -e "\e[1;33m拜拜了您嘞\e[0m"

esac

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!