參考官方文檔html
http://nginx.org/en/docs/configure.htmlnginx
--with開頭的,默認是禁用的(沒啓動的,想使用的話須要在編譯的時候加上)正則表達式
--without開頭的,默認是啓用的(不想啓用此模塊時,能夠在編譯的時候加上這個參數)瀏覽器
編譯安裝示例(從生產上貼下來的,nginx-1.16)緩存
./configure --prefix=/etc/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 --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_dav_module --with-http_stub_status_module --with-threads --with-file-aio安全
--prefix= 指向安裝目錄。服務器
--sbin-path= 指定執行程序文件存放位置。cookie
--modules-path= 指定第三方模塊的存放路徑。架構
--conf-path= 指定配置文件存放位置。併發
--error-log-path= 指定錯誤日誌存放位置。
--pid-path= 指定pid文件存放位置。
--lock-path= 指定lock文件存放位置。
--user= 指定程序運行時的非特權用戶。
--group= 指定程序運行時的非特權用戶組。
--builddir= 指向編譯目錄。
--with-rtsig_module 啓用rtsig模塊支持。
--with-select_module 啓用select模塊支持,一種輪詢處理方式,不推薦在高併發環境中使用,禁用:--without-select_module。
--with-poll_module 啓用poll模塊支持,功能與select相同,不推薦在高併發環境中使用。
--with-threads 啓用thread pool支持。
--with-file-aio 啓用file aio支持。
--with-http_ssl_module 啓用https支持。
--with-http_v2_module 啓用ngx_http_v2_module支持。
--with-ipv6 啓用ipv6支持。
--with-http_realip_module 容許從請求報文頭中更改客戶端的ip地址,默認爲關。
--with-http_addition_module 啓用ngix_http_additon_mdoule支持(做爲一個輸出過濾器,分部分響應請求)。
--with -http_xslt_module 啓用ngx_http_xslt_module支持,過濾轉換XML請求 。
--with-http_image_filter_mdoule 啓用ngx_http_image_filter_module支持,傳輸JPEG\GIF\PNG圖片的一個過濾器,默認不啓用,須要安裝gd庫。
--with-http_geoip_module 啓用ngx_http_geoip_module支持,用於建立基於MaxMind GeoIP二進制文件相配的客戶端IP地址的ngx_http_geoip_module變量。
--with-http_sub_module 啓用ngx_http_sub_module支持,容許用一些其餘文本替換nginx響應中的一些文本。
--with-http_dav_module 啓用ngx_http_dav_module支持,增長PUT、DELETE、MKCOL建立集合,COPY和MOVE方法,默認爲關閉,須要編譯開啓。
--with-http_flv_module 啓用ngx_http_flv_module支持,提供尋求內存使用基於時間的偏移量文件。
--with-http_mp4_module 啓用ngx_http_mp4_module支持,啓用對mp4類視頻文件的支持。
--with-http_gzip_static_module 啓用ngx_http_gzip_static_module支持,支持在線實時壓縮輸出數據流。
--with-http_random_index_module 啓用ngx_http_random_index_module支持,從目錄中隨機挑選一個目錄索引。
--with-http_secure_link_module 啓用ngx_http_secure_link_module支持,計算和檢查要求所需的安全連接網址。
--with-http_degradation_module 啓用ngx_http_degradation_module 支持容許在內存不足的狀況下返回204或444代碼。
--with-http_stub_status_module 啓用ngx_http_stub_status_module 支持查看nginx的狀態頁。
--without-http_charset_module 禁用ngx_http_charset_module這一模塊,能夠進行字符集間的轉換,從其它字符轉換成UTF-8或者從UTF8轉換成其它字符。它只能從服務器到客戶端方向,只有一個字節的字符能夠轉換。
--without-http_gzip_module 禁用ngx_http_gzip_module支持,同--with-http_gzip_static_module功能同樣。
--without-http_ssi_module 禁用ngx_http_ssi_module支持,提供了一個在輸入端處理服務器包含文件(SSI)的過濾器。
--without-http_userid_module 禁用ngx_http_userid_module支持,該模塊用來肯定客戶端後續請求的cookies。
--without-http_access_module 禁用ngx_http_access_module支持,提供了基於主機ip地址的訪問控制功能。
--without-http_auth_basic_module 禁用ngx_http_auth_basic_module支持,可使用用戶名和密碼認證的方式來對站點或部份內容進行認證。
--without-http_autoindex_module 禁用ngx_http_authindex_module,該模塊用於在ngx_http_index_module模塊沒有找到索引文件時發出請求,用於自動生成目錄列表。
--without-http_geo_module 禁用ngx_http_geo_module支持,這個模塊用於建立依賴於客戶端ip的變量。
--without-http_map_module 禁用ngx_http_map_module支持,使用任意的鍵、值 對設置配置變量。
--without-http_split_clients_module 禁用ngx_http_split_clients_module支持,該模塊用於基於用戶ip地址、報頭、cookies劃分用戶。
--without-http_referer_module 禁用ngx_http_referer_modlue支持,該模塊用來過濾請求,報頭中Referer值不正確的請求。
--without-http_rewrite_module 禁用ngx_http_rewrite_module支持。該模塊容許使用正則表達式改變URI,而且根據變量來轉向以及選擇配置。若是在server級別設置該選項,那麼將在location以前生效,但若是location中還有更進一步的重寫規則,location部分的規則依然會被執行。若是這個URI重寫是由於location部分的規則形成的,那麼location部分會再次被執行做爲新的URI,這個循環會被執行10次,最後返回一個500錯誤。
--without-http_proxy_module 禁用ngx_http_proxy_module支持,http代理功能。
--without-http_fastcgi_module 禁用ngx_http_fastcgi_module支持,該模塊容許nginx與fastcgi進程交互,並經過傳遞參數來控制fastcgi進程工做。
--without-http_uwsgi_module 禁用ngx_http_uwsgi_module支持,該模塊用來使用uwsgi協議,uwsgi服務器相關。
--without-http_scgi_module 禁用ngx_http_scgi_module支持,相似於fastcgi,也是應用程序與http服務的接口標準。
--without-http_memcached_module 禁用ngx_http_memcached支持,用來提供簡單的緩存,提升系統效率。
--without-http_limit_conn_module 禁用ngx_http_limit_conn_module支持,該模塊能夠根據條件進行會話的併發鏈接數進行限制。
--without-http_limit_req_module 禁用ngx_limit_req_module支持,該模塊能夠實現對於一個地址進行請求數量的限制。
--without-http_empty_gif_module 禁用ngx_http_empty_gif_module支持,該模塊在內存中常駐了一個1*1的透明gif圖像,能夠被很是快速的調用。
--without-http_browser_module 禁用ngx_http_browser_mdoule支持,建立依賴於請求報頭的值 。若是瀏覽器爲modern,則$modern_browser等於modern_browser_value的值;若是瀏覽器爲old,則$ancient_browser等於$ancient_browser_value指令分配的值;若是瀏覽器爲MSIE,則$msie等於1。
--without-http_upstream_ip_hash_module 禁用ngx_http_upstream_ip_hash_module支持,該模塊用於簡單的負載均衡。
--with-http_perl_module 啓用ngx_http_perl_module支持,它使nginx能夠直接使用perl或經過ssi調用perl。
--with-perl_modules_path= 設定perl模塊路徑
--with-perl= 設定perl庫文件路徑
--http-log-path= 設定access log路徑
--http-client-body-temp-path= 設定http客戶端請求臨時文件路徑
--http-proxy-temp-path= 設定http代理臨時文件路徑
--http-fastcgi-temp-path= 設定http fastcgi臨時文件路徑
--http-uwsgi-temp-path= 設定http scgi臨時文件路徑
--http-scgi-temp-path= 設定http scgi臨時文件路徑
--without-http 禁用http server功能
--without-http-cache 禁用http cache功能
--with-mail 啓用POP3、IMAP4、SMTP代理模塊
--with-mail_ssl_module 啓用ngx_mail_ssl_module支持
--without-mail_pop3_module 禁用pop3協議。
--without-mail_iamp_module 禁用iamp協議。
--without-mail_smtp_module 禁用smtp協議。
--with-google_perftools_module 啓用ngx_google_perftools_mdoule支持,調試用,能夠用來分析程序性能瓶頸。
--with-cpp_test_module 啓用ngx_cpp_test_module支持。
--add-module= 指定外部模塊路徑,啓用對外部模塊的支持。
--with-cc= 指向C編譯器路徑。
--with-cpp= 指向C預處理路徑。
--with-cc-opt= 設置C編譯器參數,指定--with-cc-opt="-I /usr/lcal/include",若是使用select()函數,還須要同時指定文件描述符數量--with-cc-opt="-D FD_SETSIZE=2048"。 (PCRE庫)
--with-ld-opt= 設置鏈接文件參數,須要指定--with-ld-opt="-L /usr/local/lib"。(PCRE庫)
--with-cpu-opt= 指定編譯的CPU類型,如pentium,pentiumpro,...amd64,ppc64...
--without-pcre 禁用pcre庫。
--with-pcre 啓用pcre庫。
--with-pcre= 指向pcre庫文件目錄。
--with-pcre-opt= 在編譯時爲pcre庫設置附加參數 。
--with-md5= 指向md5庫文件目錄。
--with-md5-opt= 編譯時爲md5庫設置附加參數。
--with-md5-asm 使用md5彙編源。
--with-sha1= 指向sha1庫文件目錄。
--with-sha1-opt= 編譯時爲sha1庫設置附加參數。
--with-sha1-asm 使用sha1彙編源。
--with-zlib= 指向zlib庫文件目錄。
--with-zlib-opt= 在編譯時爲zlib設置附加參數。
--with-zlib-asm= 爲指定的CPU使用匯編源進行優化。
--with-libatomic 爲原子內存的更新操做的實現提供一個架構。
--with-libatomic= 指向libatomic_ops的安裝目錄。
--with-openssl= 指向openssl安裝目錄。
--with-openssl-opt= 在編譯時爲openssl設置附加參數。
--with-debug 啓用debug日誌。
3. 默認with或without的選項
選項(功能) |
with |
without |
默認 |
prefix |
N/A |
N/A |
/usr/local/nginx |
sbin-path |
N/A |
N/A |
prefix/sbin/nginx |
conf-path |
N/A |
N/A |
prefix/conf/nginx.conf |
pid-path |
N/A |
N/A |
prefix/logs/nginx.pid |
error-log-path |
N/A |
N/A |
prefix/logs/error.log |
http-log-path |
N/A |
N/A |
prefix/logs/access.log |
user |
N/A |
N/A |
nobody |
group |
N/A |
N/A |
nobody |
select_module |
with |
without |
若是平臺不支持kqueue,epoll,/dev/poll,它將做爲自動選擇的事務處理方式 |
poll_module |
with |
without |
若是平臺不支持kqueue,epoll,/dev/poll,它將做爲自動選擇的事務處理方式 |
file_aio |
with |
N/A |
關閉 |
ipv6 |
with |
N/A |
關閉 |
http_ssl_module |
with |
N/A |
關閉 |
http_realip_module |
with |
N/A |
關閉 |
http_addition_module |
with |
N/A |
關閉 |
http_xslt_module |
with |
N/A |
關閉 |
http_image_filter_module |
with |
N/A |
關閉 |
http_geoip_module |
with |
N/A |
關閉 |
http_sub_module |
with |
N/A |
關閉 |
http_dav_module |
with |
N/A |
關閉 |
http_flv_module |
with |
N/A |
關閉 |
http_gzip_static_module |
with |
N/A |
關閉 |
http_random_index_module |
with |
N/A |
關閉 |
http_secure_link_module |
with |
N/A |
關閉 |
http_degradation_module |
with |
N/A |
關閉 |
http_stub_status_module |
with |
N/A |
關閉 |
http_charset_module |
N/A |
without |
啓用 |
http_gzip_module |
N/A |
without |
啓用 |
http_ssi_module |
N/A |
without |
啓用 |
http_userid_module |
N/A |
without |
啓用 |
http_access_module |
N/A |
without |
啓用 |
http_auth_basic_module |
N/A |
without |
啓用 |
http_autoindex_module |
N/A |
without |
啓用 |
http_geo_module |
N/A |
without |
啓用 |
http_map_module |
N/A |
without |
啓用 |
http_split_clients_module |
N/A |
without |
啓用 |
http_referer_module |
N/A |
without |
啓用 |
http_rewrite_module |
N/A |
without |
啓用 |
http_proxy_module |
N/A |
without |
啓用 |
http_fastcgi_module |
N/A |
without |
啓用 |
http_uwsgi_module |
N/A |
without |
啓用 |
http_scgi_module |
N/A |
without |
啓用 |
http_memcached_module |
N/A |
without |
啓用 |
http_limit_conn_module |
N/A |
without |
啓用 |
http_limit_req_module |
N/A |
without |
啓用 |
http_empty_gif_module |
N/A |
without |
啓用 |
http_brower_module |
N/A |
without |
啓用 |
http_upstream_ip_hash_module |
N/A |
without |
啓用 |
http_perl_module |
with |
N/A |
禁用 |
http |
N/A |
without |
啓用 |
http-cache |
N/A |
without |
啓用 |
|
with |
N/A |
禁用 |
pcre |
with |
without |
N/A |
stream |
with |
N/A |
禁用 |