一 nginx下載安裝
nginx是HTTP服務器和反向代理服務器,功能非常豐富,在nginx官網首頁,點擊download
在download頁面下,可以選擇Stable version穩定版本,點擊下載
將下載完成的zip解壓即可,然乎在nginx所在的根目錄下打開cmd窗口,執行nginx相關命令
二?nginx相關命令
啟動nginx
D:\soft\nginx\nginx-1.26.1>start nginx,常用啟動nginx命令
D:\soft\nginx\nginx-1.26.1>nginx -c nginx.conf文件路徑,指定nginx.conf配置文件啟動nginx命令,配置文件的路徑可以是相對路徑,也可以是絕對路徑
停止nginx
D:\soft\nginx\nginx-1.26.1>nginx -s stop
D:\soft\nginx\nginx-1.26.1>nginx -s quit
stop命令可以快速停止nginx服務,quit命令可以完整有序的停止nginx服務
檢測配置文件
D:\soft\nginx\nginx-1.26.1>nginx -t -c nginx.conf文件路徑
nginx: the configuration file ./conf/nginx.conf syntax is ok
nginx: configuration file ./conf/nginx.conf test is successful
nginx命令中-c參數用于指定相應的nginx配置文件,-t命令用于檢測配置文件語法的正確性
重新加載配置文件
D:\soft\nginx\nginx-1.26.1>nginx -s reload
當配置文件修改后,需要重新加載nginx服務,讓配置文件生效
查詢nginx的啟動進程
D:\soft\nginx\nginx-1.26.1>tasklist /fi "imagename eq nginx.exe"
查詢nginx版本
D:\soft\nginx\nginx-1.26.1>nginx -v
nginx version: nginx/1.26.1
D:\soft\nginx\nginx-1.26.1>nginx -V
nginx version: nginx/1.26.1
built by cl 16.00.30319.01 for 80x86
built with OpenSSL 3.0.13 30 Jan 2024
TLS SNI support enabled
configure arguments: --with-cc=cl --builddir=objs.msvc8 --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 --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre2-10.39 --with-zlib=objs.msvc8/lib/zlib-1.3.1 --with-http_v2_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_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-stream_realip_module --with-stream_ssl_preread_module --with-openssl=objs.msvc8/lib/openssl-3.0.13 --with-openssl-opt='no-asm no-tests -D_WIN32_WINNT=0x0501' --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module
查看更多的nginx命令
D:\soft\nginx\nginx-1.26.1>nginx -h
nginx version: nginx/1.26.1
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix]
? ? ? ? ? ? ?[-e filename] [-c filename] [-g directives]
Options:
? -?,-h ? ? ? ? : this help
? -v ? ? ? ? ? ?: show version and exit
? -V ? ? ? ? ? ?: show version and configure options then exit
? -t ? ? ? ? ? ?: test configuration and exit
? -T ? ? ? ? ? ?: test configuration, dump it and exit
? -q ? ? ? ? ? ?: suppress non-error messages during configuration testing
? -s signal ? ? : send signal to a master process: stop, quit, reopen, reload
? -p prefix ? ? : set prefix path (default: NONE)
? -e filename ? : set error log file (default: logs/error.log)
? -c filename ? : set configuration file (default: conf/nginx.conf)
? -g directives : set global directives out of configuration file