window nginx 基礎命令及伺服器搭建
阿新 • • 發佈:2021-12-15
window nginx 下載地址
http://nginx.org/en/download.html
nginx 命令
nginx 啟動
D:\nginx-1.18.0>nginx.exe
nginx停止
D:\nginx-1.18.0>nginx.exe -s stop #stop是快速停止nginx,可能並不儲存相關資訊 D:\nginx-1.18.0>nginx.exe -s quit #quit是完整有序的停止nginx,並儲存相關資訊。
nginx重新載入配置
D:\nginx-1.18.0>nginx.exe -s reload #當配置資訊修改,需要重新載入這些配置時使用此命令。
nginx檢視版本
D:\nginx-1.18.0>nginx -v
nginx載入指定配置檔案
D:\nginx-1.18.0>nginx.exe -t -c conf/default.conf #conf/default.conf配置檔案路徑
nginx 配置
conf/nginx.conf
server { listen 80; server_name demo1.com; #charset koi8-r; #access_log logs/host.access.log main; location / { root D:\websit\demo1; index index.html index.htm; try_files $uri $uri/ /index.html; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } server { listen 80; server_name demo2.com; location / { root D:\websit\demo2; index index.html index.htm; try_files $uri $uri/ /index.html; } } server { listen 80; server_name demo3.com; location / { root D:\websit\demo3; index index.html index.htm; try_files $uri $uri/ /index.html; } } server { listen 80; server_name demo4.com; location / { root D:\websit\demo4; index index.html index.htm; try_files $uri $uri/ /index.html; } }