1. 程式人生 > >nginx深入剖析

nginx深入剖析

highlight pid 指定 status ngx 因此 問控制 根據 配置文件

nginx軟件功能模塊說明

Nginx軟件之所以強大,是因為它具有眾多的功能模塊,下面列出了企業常用的重要模塊。(1) Nginx核心功能模塊(Core functionality)
nginx核心功能模塊負責Nginx的全局應用,主要對應主配置文件的Main區塊和Events區塊區域,這裏有很多Nginx必須的全局參數配置。有關核心功能模塊的詳細信息,請看官網,地址為http://nginx.org/en/docs/ngx_core_module.html。
(2)標準的http功能模塊集合


這些標準的http功能模塊,雖然不是nginx軟件所必需的,但都是很常用的,因此絕大部分默認情況都會自動安裝到 Nginx軟件中(見下表),不建議擅自改動,保留軟件的默認配置就好,除非你明確知道你在做什麽,有什麽額外影響。
在生產環境中,配置、調整及優化 Nginx軟件,主要就是根據這些模塊的功能修改相應的參數來實現的。通過官方地址http://nginx.org/en/docs/可以查看到上述及更多模塊的詳細使用幫助。

常用的Nginx http功能模塊匯總

Nginx http 功能模塊	               模塊說明

ngx_http_core_module	           包括一些核心的http參數配置,對應nginx的配置為HTTP區塊部分
ngx_http_access_module	        訪問控制模塊,用來控制網站用戶對Nginx的訪問
ngx_http_gzip_module	           壓縮模塊,對Nginx返回的數據壓縮,屬於性能優化模塊
ngx_http_fastcgi_module	      FastCGI模塊,和動態應用相關的模塊,例如PHP
ngx_http_proxy_module	      proxy代理模塊
ngx_http_upstream_module     負載均衡模塊,可以實現網站的負載均衡功能及節點的健康檢查
ngx_http_rewrite_module	      URL地址重寫模塊
ngx_http_limit_conn_module	          限制用戶並發連接數及請求數模塊
ngx_http_limit_req_module	           根據定義的key限制Nginx請求過程的速率
ngx_http_log_module	             訪問日誌模塊,以指定的格式記錄Nginx客戶訪問日誌等信息
ngx_http_auth_basic_module	   Web認證模塊,設置web用戶通過賬號、密碼訪問Nginx
ngx_http_ssl_module	             ssl模塊,用於加密的http連接,如htts
ngx_http_stub_status_module	   記錄Nginx基本訪問狀態信息等的模塊

nginx的目錄結構說明

[root@nginx ~]# tree /application/nginx/
/application/nginx/
├── client_body_temp
├── conf
│   ├── fastcgi.conf
│   ├── fastcgi.conf.default
│   ├── fastcgi_params
│   ├── fastcgi_params.default
│   ├── koi-utf
│   ├── koi-win
│   ├── mime.types
│   ├── mime.types.default
│   ├── nginx.conf
│   ├── nginx.conf.default
│   ├── scgi_params
│   ├── scgi_params.default
│   ├── uwsgi_params
│   ├── uwsgi_params.default
│   └── win-utf
├── fastcgi_temp
├── html
│   ├── 50x.html
│   └── index.html
├── logs
│   ├── access.log
│   ├── error.log
│   └── nginx.pid
├── proxy_temp
├── sbin
│   └── nginx
├── scgi_temp
└── uwsgi_temp

9 directories, 21 files

nginx的主配置文件 nginx.conf

nginx的主配置文件

nginx深入剖析