/ 中存储网

Nginx服务器配置检测脚本

2014-03-24 10:27:01 来源:kejihao
%NGINX_DIR%/nginx.exe -t

返回结果例如:

nginx: the configuration file C:nginx-1.1.5/conf/nginx.conf syntax is ok

nginx: configuration file C:nginx-1.1.5/conf/nginx.conf test is successful 可以把检测配置文件项放到Nginx操作的bat文件里,

cls

@ECHO OFF

SET NGINX_PATH=C:

SET NGINX_DIR=C:nginx-1.1.5

color 0a

TITLE Nginx管理程序

GOTO MENU

:MENU

CLS

ECHO.

ECHO. * * * *  Nginx Management  * * *

ECHO. *                                *

ECHO. *   1 启动Nginx                  *

ECHO. *                                *

ECHO. *   2 关闭Nginx                  *

ECHO. *                                *

ECHO. *   3 重启Nginx                  *

ECHO. *                                *

ECHO. *   4 检查配置                   *

ECHO. *                                *

ECHO. *   5 退 出                      *

ECHO. *                                *

ECHO. * * * * * * * * * * * * * * * * *

ECHO.

ECHO.请输入命令编号:

set /p ID=

IF "%id%"=="1" GOTO cmd1

IF "%id%"=="2" GOTO cmd2

IF "%id%"=="3" GOTO cmd3

IF "%id%"=="4" GOTO cmd4

IF "%id%"=="5" EXIT

PAUSE

:cmd1

ECHO.

ECHO.启动Nginx......

IF NOT EXIST %NGINX_DIR%nginx.exe ECHO %NGINX_DIR%nginx.exe不存在

%NGINX_PATH%

cd %NGINX_DIR%

IF EXIST %NGINX_DIR% start %NGINX_DIR%nginx.exe

ECHO.OK

PAUSE

GOTO MENU

:cmd2

ECHO.

ECHO.关闭Nginx......

taskkill /F /IM nginx.exe > nul

ECHO.OK

PAUSE

GOTO MENU

:cmd3

ECHO.

ECHO.关闭Nginx......

taskkill /F /IM nginx.exe > nul

ECHO.OK

GOTO cmd1

GOTO MENU

:cmd4

ECHO.

ECHO.检查Nginx配置......

IF NOT EXIST %NGINX_DIR%nginx.exe ECHO %NGINX_DIR%nginx.exe不存在

%NGINX_PATH%

cd %NGINX_DIR%

IF EXIST %NGINX_DIR% %NGINX_DIR%nginx.exe -t

ECHO.完成检查

PAUSE

GOTO MENU