%NGINX_DIR%/nginx.exe -t
返回结果例如:
nginx: the configuration file C:\nginx-1.1.5/conf/nginx.conf syntax is oknginx: configuration file C:\nginx-1.1.5/conf/nginx.conf test is successful
可以把检测配置文件项放到 Nginx 操作的 bat 文件里,代码如下:
cls@ECHO OFFSET NGINX_PATH=C:SET NGINX_DIR=C:\nginx-1.1.5\color 0aTITLE Nginx管理程序GOTO MENU:MENUCLSECHO.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 cmd1IF "%id%"=="2" GOTO cmd2IF "%id%"=="3" GOTO cmd3IF "%id%"=="4" GOTO cmd4IF "%id%"=="5" EXITPAUSE:cmd1ECHO.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.exeECHO.OKPAUSEGOTO MENU:cmd2ECHO.ECHO.关闭Nginx......taskkill /F /IM nginx.exe > nulECHO.OKPAUSEGOTO MENU:cmd3ECHO.ECHO.关闭Nginx......taskkill /F /IM nginx.exe > nulECHO.OKGOTO cmd1GOTO MENU:cmd4ECHO.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 -tECHO.完成检查PAUSEGOTO MENU