nginx可视化bat命令

@echo off
:: 设置 nginx 的安装目录(请根据实际情况修改)
set NGINX_PATH=C:\Program Files\nginx\nginx-1.25.3

title Nginx 控制面板

:start
cls
echo.
echo ================== Nginx 控制菜单 ==================
echo.
echo 1. 启动 Nginx
echo 2. 关闭 Nginx
echo 3. 重启 Nginx
echo 4. 查看 Nginx 运行状态
echo 5. 退出
echo.
set /p choice=请输入选项 (1-5): 

if "%choice%"=="1" goto start_nginx
if "%choice%"=="2" goto stop_nginx
if "%choice%"=="3" goto restart_nginx
if "%choice%"=="4" goto check_status
if "%choice%"=="5" exit

echo 无效的输入,请重新选择。
pause
goto start

:start_nginx
echo 正在启动 Nginx...
cd /d "%NGINX_PATH%"
start nginx
echo Nginx 已启动。
pause
goto start

:stop_nginx
echo 正在停止 Nginx...
taskkill /f /im nginx.exe >nul 2>&1
echo Nginx 已停止。
pause
goto start

:restart_nginx
echo 正在重启 Nginx...
call :stop_nginx
timeout /t 2 >nul
call :start_nginx
echo Nginx 已重启。
pause
goto start

:check_status
echo 正在检查 Nginx 是否运行...
tasklist | findstr /i "nginx.exe" >nul 2>&1
if %errorlevel% == 0 (
    echo Nginx 正在运行。
) else (
    echo Nginx 未运行。
)
pause
goto start

如果中文显示乱码,文件另存为,编码设置成ANSI

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值