shell脚本启动NGINX、MySQL、PHP --- 2021-05-14

  1. 脚本内容
#!/bin/bash
echo 'MySQL Nginx PHP 启动脚本'

echo '启动 MySQL 请输入 1'
echo '启动 Nginx 请输入 2'
echo '启动 PHP   请输入 3'

echo '重启 MySQL 请输入 4'
echo '重启 Nginx 请输入 5'
echo '重启 PHP   请输入 6'

echo '停止 MySQL 请输入 7'
echo '停止 Nginx 请输入 8'
echo '停止 PHP   请输入 9'

echo '重启 MySQL、Nginx、PHP 请输入 10'
echo '停止 MySQL、Nginx、PHP 请输入 11'
echo '启动 MySQL、Nginx、PHP 请输入 0'

read aNum

case $aNum in
    1) brew services start [email protected] ;;
    2) brew services start nginx ;;
    3) brew services start [email protected] ;;

    4) brew services restart [email protected] ;;
    5) brew services restart nginx ;;
    6) brew services restart [email protected] ;;

    7) brew services stop [email protected] ;;
    8) brew services stop nginx ;;
    9) brew services stop [email protected] ;;

    10) 
        brew services restart [email protected]
        brew services restart nginx
        brew services restart [email protected]
    ;;
    11) 
        brew services stop [email protected]
        brew services stop nginx
        brew services stop [email protected]
    ;;
    *) 
        brew services start [email protected]
        brew services start nginx
        brew services start [email protected]
    ;;
    esac

echo '启动服务成功!'
  1. 给文件权限
chmod +x ./MsqlNginxPhpStart.sh
  1. 运行脚本
./MsqlNginxPhpStart.sh

你可能感兴趣的:(shell脚本启动NGINX、MySQL、PHP --- 2021-05-14)