Nginx安装启动shell脚本
2021/8/27 7:07:22
本文主要是介绍Nginx安装启动shell脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#!/bin/bash
ls /usr/local/nginx/sbin/nginx >/dev/null 2>&1
if [ $? != 0 ]
then
echo "没有发现源码版nginx,是否需要安装"
read -p "yes / no :" b
if [ $b = yes ]
then
echo "开始安装nginx源码包,请稍候"
sh nginxinstall.sh
else
echo "没有nginx程序,无法执行"
exit
fi
fi
start="/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf"
stop="kill `ps aux|grep nginx|grep master|awk '{print $2}'`"
echo "1=启动 2=停止 3=重启 4=查看运行"
read -p "请输入指令:" a
case $a in
1)
ps aux|grep nginx| grep master > /dev/null
if [ $? = 0 ]
then
echo "nginx 已经启动"
else
$start 2> /dev/null
ps aux|grep nginx| grep master > /dev/null
if [ $? = 0 ]
then
echo "nginx启动成功"
else
echo "nginx启动失败"
fi
fi
;;
2)
ps aux|grep nginx| grep master > /dev/null
if [ $? = 0 ]
then
$stop
ps aux|grep nginx| grep master > /dev/null
if [ $? = 0 ]
then
echo "nginx 关闭失败"
else
echo "nginx 关闭成功"
fi
else
echo "nginx 没有运行"
fi
;;
3)
ps aux|grep nginx| grep master > /dev/null
if [ $? = 0 ]
then
$stop
ps aux|grep nginx| grep master > /dev/null
if [ $? = 0 ]
then
echo "nginx 关闭失败"
else
echo "nginx 关闭成功"
fi
else
echo "nginx 没有运行"
fi
ps aux|grep nginx| grep master > /dev/null
if [ $? = 0 ]
then
echo "nginx 已经启动"
else
$start 2> /dev/null
ps aux|grep nginx| grep master > /dev/null
if [ $? = 0 ]
then
echo "nginx启动成功"
else
echo "nginx启动失败"
fi
fi
;;
4)
ps aux|grep nginx| grep master > /dev/null
if [ $? = 0 ]
then
echo "nginx 正在运行"
else
echo "nginx 没有运行"
fi
;;
*)
echo " 请输入 1 2 3 4"
;;
esac
这篇关于Nginx安装启动shell脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29fail2ban nginx
- 2024-03-18install nginx proxy manager
- 2024-01-2444从零开始用Rust编写nginx,命令行参数的设计与解析及说明
- 2024-01-22比Nginx更好用的Gateway!
- 2024-01-17nginx daemon off
- 2023-12-30Nginx Vhost Traffic Status 是什么意思-icode9专业技术文章分享
- 2023-12-26使用nginx搭建creates.io镜像(稀疏索引)
- 2023-11-18centos7编译安装Nginx教程。
- 2023-11-02nginx启动命令和停止命令
- 2023-10-25Centos7系统Nginx负载均衡如何安装和配置?