# Nginx 快速启动和停止
在 nginx 根目录创建nginx.bat
批处理文件,填入下面的内容,并且将NGINX_PATH
和 NGINX_DIR
的路径修改
@echo off
echo
SET NGINX_PATH=E:
SET NGINX_DIR=E:\nginx-1.16.1\
color 0a
TITLE Nginx Control Panel
ECHO.
ECHO. * Nginx Control Panel *
ECHO.
:MENU
ECHO. * nginx *
ECHO.
ECHO. [1] start Nginx
ECHO. [2] close Nginx
ECHO. [3] restart Nginx
ECHO. [4] exit Nginx
ECHO.
ECHO. Please enter:
set /p ID=
IF "%id%"=="1" GOTO start
IF "%id%"=="2" GOTO stop
IF "%id%"=="3" GOTO restart
IF "%id%"=="4" EXIT
PAUSE
:start
call :startNginx
GOTO MENU
:stop
call :shutdownNginx
GOTO MENU
:restart
call :shutdownNginx
call :startNginx
GOTO MENU
:shutdownNginx
ECHO.
ECHO. close Nginx......
taskkill /F /IM nginx.exe > nul
ECHO.OK,Close all Nginx processes
goto :eof
:startNginx
ECHO.
ECHO.start Nginx......
IF NOT EXIST "%NGINX_DIR%nginx.exe" ECHO "%NGINX_DIR%nginx.exe" nothingness
%NGINX_PATH%
cd "%NGINX_DIR%"
IF EXIST "%NGINX_DIR%nginx.exe" (
echo "start '' nginx.exe"
start "" nginx.exe
)
ECHO.OK
goto :eof
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# 常用的 Nginx 的命令
start nginx:启动nginx
nginx -s stop:关闭nginx
nginx -s reload:重新加载配置
nginx -s reopen:重新打开
nginx -t:检测配置文件是否正常
taskkill /IM nginx.exe /F 关闭所有nginx进程
taskkill /im chrome.exe /F 关闭所有chrome进程
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13