windows-nginx安裝與運行靜態資源


windows-nginx 官網

http://nginx.org/en/docs/windows.html 點擊跳轉

安裝包下載

http://nginx.org/en/download.html 點擊跳轉

下載后解壓,解壓后如下

解壓圖片

啟動nginx

  1. 直接雙擊nginx.exe,雙擊后一個黑色的彈窗一閃而過
  2. 打開cmd命令窗口,切換到nginx解壓目錄下,輸入命令 nginx.exe 或者 start nginx ,回車即可

運行圖片

檢查nginx是否啟動成功

  1. 直接在瀏覽器地址欄輸入網址 http://localhost:80,回車,出現以下頁面說明啟動成功
    檢查nginx是否啟動成功
  2. 在cmd命令窗口輸入命令 tasklist /fi "imagename eq nginx.exe" ,出現如下結果說明啟動成功
    檢查nginx是否啟動成功

關閉nginx

  1. 輸入nginx命令 nginx -s stop(快速停止nginx) 或 nginx -s quit(完整有序的停止nginx)
  2. 使用taskkill taskkill /f /t /im nginx.exe

nginx配置

nginx的配置文件是conf目錄下的nginx.conf,默認配置的nginx監聽的端口為80

1

運行靜態資源

將靜態資源(如jpg|png|css|js等)放在如下配置的F:\front\dist目錄下,然后在nginx配置文件中做如下配置(注意:靜態資源配置只能放在 location / 中),瀏覽器中訪問 http://192.168.1.105:9090/module/index.html 即可訪問到 F:\front\dist 目錄下的頁面

2

3

配置文件 proxy.conf 放在conf目錄下

    proxy_http_version 1.1;
    proxy_connect_timeout 300s;
    proxy_send_timeout 900;
    proxy_read_timeout 7200s;
    proxy_headers_hash_max_size 51200;
    proxy_headers_hash_bucket_size 6400;
    proxy_buffer_size 32k;
    proxy_buffers 4 64k;
    proxy_busy_buffers_size 128k;
    proxy_redirect off;
    proxy_hide_header Vary;
    proxy_set_header Accept-Encoding '';
    proxy_set_header Referer $http_referer;
    proxy_set_header Cookie $http_cookie;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


免責聲明!

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



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