{"id":158,"date":"2024-10-30T18:17:53","date_gmt":"2024-10-30T10:17:53","guid":{"rendered":"https:\/\/zhoujibin.com\/?p=158"},"modified":"2024-10-30T18:17:53","modified_gmt":"2024-10-30T10:17:53","slug":"windows%e4%b8%8bnginx%e5%90%af%e5%8a%a8%e3%80%81%e5%85%b3%e9%97%ad%e5%8f%af%e8%a7%86%e5%8c%96%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/zhoujibin.com\/?p=158","title":{"rendered":"Windows\u4e0bNginx\u542f\u52a8\u3001\u5173\u95ed\u53ef\u89c6\u5316\u811a\u672c"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>@echo off\nrem \u63d0\u4f9bWindows\u4e0bnginx\u7684\u542f\u52a8\uff0c\u91cd\u542f\uff0c\u5173\u95ed\u529f\u80fd\n\necho ==================begin========================\n\ncls\n::ngxin \u6240\u5728\u7684\u76d8\u7b26\nset NGINX_PATH=D:\n\n::nginx \u6240\u5728\u76ee\u5f55\nset NGINX_DIR=D:\\program-dev\\nginx-1.21.6\\\ncolor 0a\nTITLE Nginx \u7ba1\u7406\u7a0b\u5e8f\u589e\u5f3a\u7248\n\nCLS\n\necho.\necho. ** Nginx \u7ba1\u7406\u7a0b\u5e8f  ***\necho. *** create 2017-09-22 ***\necho.\n\n:MENU\n\necho. ***** nginx \u8fdb\u7a0blist ******\n::tasklist|findstr \/i \"nginx.exe\"\ntasklist \/fi \"imagename eq nginx.exe\"\n\necho.\n\n    if ERRORLEVEL 1 (\n        echo nginx.exe\u4e0d\u5b58\u5728\n    ) else (\n        echo nginx.exe\u5b58\u5728\n    )\n\necho.\n::*************************************************************************************************************\necho.\n    echo.  &#91;1] \u542f\u52a8Nginx \n    echo.  &#91;2] \u5173\u95edNginx \n    echo.  &#91;3] \u91cd\u542fNginx\n    echo.  &#91;4] \u5237\u65b0\u63a7\u5236\u53f0 \n    echo.  &#91;5] \u91cd\u65b0\u52a0\u8f7dNginx\u914d\u7f6e\u6587\u4ef6\n    echo.  &#91;6] \u68c0\u67e5\u6d4b\u8bd5nginx\u914d\u7f6e\u6587\u4ef6\n    echo.  &#91;7] \u67e5\u770bnginx version\n    echo.  &#91;0] \u9000 \u51fa\necho.\n\necho.\u8bf7\u8f93\u5165\u9009\u62e9\u7684\u5e8f\u53f7:\nset \/p ID=\n    IF \"%id%\"==\"1\" GOTO start\n    IF \"%id%\"==\"2\" GOTO stop\n    IF \"%id%\"==\"3\" GOTO restart\n    IF \"%id%\"==\"4\" GOTO MENU\n    IF \"%id%\"==\"5\" GOTO reloadConf\n    IF \"%id%\"==\"6\" GOTO checkConf\n    IF \"%id%\"==\"7\" GOTO showVersion\n    IF \"%id%\"==\"0\" EXIT\nPAUSE\n\n::*************************************************************************************************************\n::\u542f\u52a8\n:start\n    call :startNginx\n    GOTO MENU\n\n::\u505c\u6b62\n:stop\n    call :shutdownNginx\n    GOTO MENU\n\n::\u91cd\u542f\n:restart\n    call :shutdownNginx\n    call :startNginx\n    GOTO MENU\n\n::\u68c0\u67e5\u6d4b\u8bd5\u914d\u7f6e\u6587\u4ef6\n:checkConf\n    call :checkConfNginx\n    GOTO MENU\n\n::\u91cd\u65b0\u52a0\u8f7dNginx\u914d\u7f6e\u6587\u4ef6\n:reloadConf\n    call :checkConfNginx\n    call :reloadConfNginx\n    GOTO MENU\n\n::\u663e\u793anginx\u7248\u672c\n:showVersion\n    call :showVersionNginx\n    GOTO MENU  \n\n\n::*************************************************************************************\n::\u5e95\u5c42\n::*************************************************************************************\n:shutdownNginx\n    echo.\n    echo.\u5173\u95edNginx......\n    taskkill \/F \/IM nginx.exe &gt; nul\n    echo.OK,\u5173\u95ed\u6240\u6709nginx \u8fdb\u7a0b\n    goto :eof\n\n:startNginx\n    echo.\n    echo.\u542f\u52a8Nginx......\n    IF NOT EXIST \"%NGINX_DIR%nginx.exe\" (\n        echo \"%NGINX_DIR%nginx.exe\"\u4e0d\u5b58\u5728\n        goto :eof\n     )\n\n    %NGINX_PATH%\n    cd \"%NGINX_DIR%\"\n\n    IF EXIST \"%NGINX_DIR%nginx.exe\" (\n        echo \"start '' nginx.exe\"\n        start \"\" nginx.exe\n    )\n    echo.OK\n    goto :eof\n\n\n\n:checkConfNginx\n    echo.\n    echo.\u68c0\u67e5\u6d4b\u8bd5 nginx \u914d\u7f6e\u6587\u4ef6......\n    IF NOT EXIST \"%NGINX_DIR%nginx.exe\" (\n        echo \"%NGINX_DIR%nginx.exe\"\u4e0d\u5b58\u5728\n        goto :eof\n     )\n\n    %NGINX_PATH%\n    cd \"%NGINX_DIR%\"\n    nginx -t -c conf\/nginx.conf\n\n    goto :eof\n\n::\u91cd\u65b0\u52a0\u8f7d nginx \u914d\u7f6e\u6587\u4ef6\n:reloadConfNginx\n    echo.\n    echo.\u91cd\u65b0\u52a0\u8f7d nginx \u914d\u7f6e\u6587\u4ef6......\n    IF NOT EXIST \"%NGINX_DIR%nginx.exe\" (\n        echo \"%NGINX_DIR%nginx.exe\"\u4e0d\u5b58\u5728\n        goto :eof\n     )\n\n    %NGINX_PATH%\n    cd \"%NGINX_DIR%\"\n    nginx -s reload\n\n    goto :eof\n\n::\u663e\u793anginx\u7248\u672c\n:showVersionNginx\n    echo.\n    %NGINX_PATH%\n    cd \"%NGINX_DIR%\"\n    nginx -V\n    goto :eof<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[33,42],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-windows","tag-nginx","tag-windows"],"_links":{"self":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts\/158"}],"collection":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=158"}],"version-history":[{"count":1,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":159,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions\/159"}],"wp:attachment":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}