1. 程式人生 > >nginx編譯參數的內容

nginx編譯參數的內容

解壓縮 sbin 編譯 user 性能 secure ati log lte

最近公司安排我安裝幾臺雲服務器環境 采用nginx做反向代理;

查了一下官方文檔,參數比較多,很多在上線後 可能才知道註意一下的。

編譯安裝nginx的話 需要安裝一些前置組件;

1.gcc環境;用於編譯官方下載的源碼包

e.g:yum install gcc-c++

2.zlib庫; nginx的gzip需要使用zlib庫

e.g:yum install -y zlib zlib-devel

3.perl庫-PCRE;nginx中的http模塊的東西需要pcre來解析

e.g:yum install -y pcre pcre-devel

4.OpenSS; 提供ssl協議,部分秘鑰的支持;

e.g:yum install -y openssl openssl-devel

通過wget到nginx的gz文件,然後解壓。

{nginx解壓路徑}/configure 可以直接運行configure進行編譯;註重自定義以及維護掌握的話。可以研究下編譯的參數

有大部分的參數:

直接安裝成功後也可以使用nginx -V查看編譯參數

--prefix=/etc/nginx 
--sbin-path=/usr/sbin/nginx 
--conf-path=/etc/nginx/nginx.conf 
--error-log-path=/var/log/nginx/error.log 
--http-log
-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp
--user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module

官方提供的參數:

--with-cc=<path> 如果想設置一個不在默認path下的c編譯器

--with-cpp=<path> 設置c預處理器的相對路徑

--with-cc-opt=<options> 指定必要的include文件路徑,可能d(-I<path>)指出,也可能是優化(-O4)和指定一個64位構建 (完全看不懂啊)

--with-ld-opt=<options> 包含連接庫的路徑和運行路徑

-with-cpu-opt=<cpu> 通過該選項為特定cpu構建nginx

--with-mail 激活POP3/IMAP4/SMTP代理模塊,默認未激活

--with-mail_ssl_module 允許ngx_mail_ssl_module模塊 這個模塊使得POP3/IMAP/SMTP可以使用SSL/TLS.配置已經定義了HTTP SSL模塊,但是不支持客戶端證書檢測

--without-mail_pop3_module 啟用mail模塊後,單獨禁用pop3模塊

--without-mail_imap_module 啟用mail模塊後,單獨禁用imap模塊

--without-mail_smtp_module 啟用mail模塊後,單獨禁用smtp模塊

--without-http 完全禁用http模塊,如果只想支持mall,可以使用此項設置

--with-openssl=DIR 設定OpenSSL庫文件路徑

--without-http-cache 在使用upstream模塊時,nginx能夠配置本地緩存內容,此選項可禁用緩存

--with-http_perl_module 這個模塊允許nginx使用SSI調用perl或直接執行perl(使用會降低性能)

--with-perl_modules_path=PATH 設置perl模塊路徑(perl解析器路徑)

--with-perl_modules_path=PATH 設置perl模塊路徑

--http-log-path=PATH 設置access log文件路徑

--http-client-body-temp-path=PATH 設置客戶端請求臨時文件路徑,如果WebDAV啟用,推薦設置該路徑為同一文件系統上的目錄作為最終的目的地

--http-proxy-temp-path=PATH 代理設置後,設置http proxy臨時文件路徑

--http-fastcgi-temp-path=PATH 設置http fastcgi臨時文件路徑

--with-http_ssl_module 如果需要對流量加密.可使用此選項,在urls中開始部分將會是https(需要openssl庫)

--with-http_realip_module 允許ngx_http_realip_module模塊(mod_rpaf)

--with-http_addition_module 作為一個輸出過濾器,使你能夠在請求經過一個location前或後時在該location本身添加內容

--with-http_xslt_module 這個模塊是一個過濾器,它可以通過XSLT模板轉換XML應答

--with-http_image_filter_module 圖像過濾器,在將圖像投遞到客戶之前進行處理(需要libgd庫)

--with-http_geoip_module 使用該模塊使用該模塊,能夠設置設置個中變量以便在配置區段中使用

--with-http_sub_module 允許ngx_http_sub_module模塊,這個模塊可以能夠在nginx的應答中搜索並替換文本

--with-http_dav_module 允許ngx_http_dav_module模塊(mod_dav) 為文件和目錄指定權限,限制不同類型的用戶對於頁面有不同的操作權限

--with-http_flv_module 允許ngx_http_flv_module模塊(mod_flvx) 這個模塊支持對FLV(flash)文件的拖動播放

--with-http_mp4_module 支持H.264/AAC文件為偽流媒體

--with-http_gzip_static_module 允許ngx_http_gzip_static_module模塊(mod_dflate) 這個模塊在一個預壓縮文件傳送到開啟Gzip壓縮的客戶端之前檢查是否已經存在以“.gz”結尾的壓縮文件,這樣可以防止文件被重復壓縮

--with-http_gunzip_module 對於不支持gzip編碼的客戶,該模塊用於為客戶解壓縮預壓縮內容

--with-http_random_index_module 允許ngx_http_random_index_module模塊(mod_autoindex),從目錄中選擇一個隨機主頁

--with-http_secure_link_module 該模塊提供一種機制,它會將一個哈希值鏈接到一個url中,因此,只有那些使用正確的密碼能夠計算鏈接

--with-http_stub_status_module 這個模塊可以取得一些nginx的運行狀態,如果是工業狀況,可以直接取消

大部分模塊並不一定要設置;具體需要根據業務場景以及業務類型去做具體的設置;

nginx編譯參數的內容