Windows 10 Install Nginx - IT 484

Windows 10 Install Nginx – IT 484

  • Post author:
  • Post category:IT / Nginx
  • Post comments:0 Comments
  • Post last modified:2023-01-13

相較於其它的 Web Server ,安裝非常簡單,可以大幅地節省工程師開發與部署的時間,實作架設 Server,可以使用直接下載檔案,解開後建立設定檔及批次檔執行。

簡介

Nginx 是一個異步框架的網頁伺服器,用於處理併發請求,整體是採用模組化設計,組態檔案也非常簡潔容易設定,同時也提供了反向代理、負載平衡器、HTTP 快取等功能,相較於 Apache、lighttpd 具有占有內存少,穩定性高等優勢,能保持低資源低消耗高性能,在網際網路項目中廣泛應用。

安裝套件

Windows 10 Install Nginx

下載檔案。

下載後,解開壓縮到 C:\nginx

組態設定

這是主要的組態檔,參考此檔案的內容,視需求而調整設定。

worker_processes # 執行緒數量
events.worker_connections # 連線數
http.include # 引用其他組態檔

開啟檔案總管,編輯檔案。
C:\nginx\conf\nginx.conf

#user  nobody;
worker_processes  auto;

error_log  logs/error.log;
error_log  logs/error.log  notice;
error_log  logs/error.log  info;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    include conf.d/*.conf;
}

運行管理

啟動服務

命令提示字元,使用 start nginx 啟動服務。

cd C:\nginx
start nginx

服務熱載入

修改設定檔後,使用 nginx reload 重新載入設定,立即生效。

cd C:\nginx
nginx -s reload

停止服務

啟動服務後,使用 nginx stop 命令終止服務運行。

cd C:\nginx
nginx -s stop

狀態驗證

Install Nginx Windows 命令提示字元,查看服務狀況。


tasklist /fi "imagename eq nginx.exe"

映像名稱                       PID 工作階段名稱      工作階段 #    RAM使用量
========================= ======== ================ =========== ============
nginx.exe                     1868 Console                   18      7,204 K
nginx.exe                    13220 Console                   18      7,504 K
nginx.exe                    10184 Console                   18      7,464 K
nginx.exe                     6644 Console                   18      7,512 K
nginx.exe                    11940 Console                   18      7,460 K
nginx.exe                    13612 Console                   18      7,468 K
nginx.exe                     2792 Console                   18      7,472 K
</pre>   

心得分享

Windows Install Nginx 快速安裝後,便於個人電腦、筆電在開發研究或測試時使用,省略複雜的設定,所以沒有參數需要調整,簡單快速建置就能使用服務,除此之外還有其他平台:

發佈留言