1. 程式人生 > >Web項目之Nginx配置文件篇

Web項目之Nginx配置文件篇

Nginx nginx.conf

2)配置篇
2.1:nginx.conf為主配置文件
2.1.1:nnginx.conf文件是以{}作區域分隔的純文本配置文件。
2.1.2?Nginx配置文件目錄結構

使用tree命令查看目錄結構,若提示-bash:?tree: command not found?則使用:yum install? -y tree

tree /usr/local/nginx/

總結配置文件分布規律:以*.default結尾的為默認的備份文件? ?帶temp字樣的為臨時目錄或文件
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服務主配置文件
|? ? ?|-- nginx.conf.default
|? ? ?|-- scgi_params
|? ? ?|-- scgi_params.default
|? ? ?|-- uwsgi_params
|? ? ?|-- uwsgi_params.default
|? ? ?`-- win-utf
|----fastcgi_temp
|-- html? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #安裝Nginx的默認站點目錄
|? ? |-- 50x.html
|? ? ?-- index.html
|? ? ---- logs? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??#安裝Nginx後默認的日誌目錄
|? ? ? ? |-- access.log? ? ? ? ? ? ? ? ? ? ? ?#訪問日誌
|? ? ? ? |-- error.log? ? ? ? ? ? ? ? ? ? ? ? ? ? #錯誤日誌
| -- nginx.pid
|-- proxy_temp
|-- sbin? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #可執行主程序文件夾
|? ? ? ? ?-- nginx? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#Nginx主程序
|-- scgi_temp
-- uwsgi_temp

2.1.3:Nginx功能模塊

Nginx之所以流行,是因為它具有強大的模塊功能。常用的模塊有:

Nginx核心模塊

為Nginx配置文件的全局應用。

vim? /usr/local/nginx/conf/nginx.conf.default

接下來為標準Http功能模塊

其中包含了基本常用的模塊

ngx_http_core_module? ?
ngx_http_access_module? ?
ngx_http_gzip_module
ngx_http_ssl_module
ngx_http_status_module? ? ?#單獨添加
ngx_http_auth_basic_module

Web項目之Nginx配置文件篇