Windows下Nginx的啟動、停止等命令


Windows下Nginx的啟動、停止等命令

可以進入到nginx的安裝根目錄,執行nginx.exe -h

在Windows下使用Nginx,我們需要掌握一些基本的操作命令,比如:啟動、停止Nginx服務,重新載入Nginx等,下面我就進行一些簡單的介紹。
1、啟動:

C:\server\nginx-1.0.2>start nginx

C:\server\nginx-1.0.2>nginx.exe

注:建議使用第一種,第二種會使你的cmd窗口一直處於執行中,不能進行其他命令操作。

如果需要特殊設置nginx的配置文件路徑,可以這樣執行start nginx -c conf/nginx.conf

2、停止:

C:\server\nginx-1.0.2>nginx.exe -s stop

C:\server\nginx-1.0.2>nginx.exe -s quit

注:stop是快速停止nginx,可能並不保存相關信息;quit是完整有序的停止nginx,並保存相關信息。

執行 nginx.exe -s stop或者quit命令是不是不能刪除進程?查看進程開了一堆nignx.exe
還有80端口在Listening,並且瀏覽器F5刷新還能訪問頁面,可能nginx.exe版本或系統的原因,用
taskkill /f /im nginx.exe > null 殺死nginx進程

3、重新載入Nginx:

C:\server\nginx-1.0.2>nginx.exe -s reload

當配置信息修改,需要重新載入這些配置時使用此命令。

4、重新打開日志文件:

C:\server\nginx-1.0.2>nginx.exe -s reopen

5、查看Nginx版本:

C:\server\nginx-1.0.2>nginx -v

nginx: nginx version: nginx/1.0.2

C:\server\nginx-1.0.2>nginx -V

nginx: nginx version: nginx/1.0.2 
nginx: TLS SNI support enabled 
nginx: configure arguments: --builddir=objs.msvc8 --crossbuild=win32 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre-7.9 --with-zlib=objs.msvc8/lib/zlib-1.2.3 --with-select_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-mail --with-ipv6 --with-openssl=objs.msvc8/lib/openssl-0.9.8r --with-openssl-opt=enable-tlsext --with-http_ssl_module --with-mail_ssl_module

注:v只是簡單顯示版本信息,V不但顯示版本信息,還顯示配置參數信息。

 

 <strong>注意不要直接雙擊nginx.exe,這樣會導致修改配置后重啟、停止nginx無效,需要手動關閉任務管理器內的所有nginx進程 在nginx.exe目錄,打開命令行工具,用命令 啟動/關閉/重啟nginx start nginx : 啟動nginx nginx -s reload :修改配置后重新加載生效 nginx -s reopen :重新打開日志文件 nginx -t -c /path/to/nginx.conf 測試nginx配置文件是否正確 關閉nginx: nginx -s stop :快速停止nginx nginx -s quit :完整有序的停止nginx 如果遇到報錯: bash: nginx: command not found 有可能是你再linux命令行環境下運行了windows命令, 如果你之前是允許 nginx -s reload報錯, 試下 ./nginx -s reload 或者 用windows系統自帶命令行工具運行</strong>

 

6、測試或載入指定配置文件:
注意,修改了配置文件后最好先檢查一下修改過的配置文件是否正 確,以免重啟后Nginx出現錯誤影響服務器穩定運行。判斷Nginx配置是否正確命令如下:

C:\server\nginx-1.0.2>nginx.exe -t -c conf/default.conf

nginx: the configuration file C:\server\nginx-1.0.2/conf/default.conf syntax isok
nginx: configuration file C:\server\nginx-1.0.2/conf/default.conf test is successful

載入指定配置文件

C:\server\nginx-1.0.2>start nginx.exe -c conf/default.conf


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM