1. 記在前面
configure時遇到錯誤
nginx在編譯安裝時,進入其源碼解壓目錄后,使用./configure
指令可以帶上如下這些參數(shù)進行自定義編譯安裝,如果在編譯時遇到錯誤,一般是相應的依賴軟件包沒有安裝的,可以根據(jù)with后的名稱,安裝相應軟件包的devel程序,如--with-http_ssl_module
要是報錯找不到ssl相關的配置或者文件,可以執(zhí)行yum install -y openssl-devel
,將openssl
和openssl-devel
及其依賴包安裝上,然后再次執(zhí)行./configure
指令一般即可configure成功。with和without
我個人理解:凡是./configure
指令后只能使用without
選項的功能或者模塊,其默認不明確指定時即為with
即啟用狀態(tài)或者支持某功能的狀態(tài)。
只能使用with
選項的功能或者模塊,其默認不指定時即為不支持或者關閉狀態(tài)。
對于即可以with
又可以without
的功能或模塊則務必根據(jù)需求進行明確指定。
2. nginx的configure參數(shù)
下面是nginx源碼程序的configure參數(shù):
-
--prefix=
指向安裝目錄。 -
--sbin-path=
指定執(zhí)行程序文件存放位置。 -
--modules-path=
指定第三方模塊的存放路徑。 -
--conf-path=
指定配置文件存放位置。 -
--error-log-path=
指定錯誤日志存放位置。 -
--pid-path=
指定pid文件存放位置。 -
--lock-path=
指定lock文件存放位置。 -
--user=
指定程序運行時的非特權用戶。 -
--group=
指定程序運行時的非特權用戶組。 -
--builddir=
指向編譯目錄。 -
--with-rtsig_module
啟用rtsig模塊支持。 -
--with-select_module
啟用select模塊支持,一種輪詢處理方式,不推薦在高并發(fā)環(huán)境中使用,禁用:--without-select_module。 -
--with-poll_module
啟用poll模塊支持,功能與select相同,不推薦在高并發(fā)環(huán)境中使用。 -
--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支持,過濾轉(zhuǎn)換XML請求 。 -
--with-http_image_filter_mdoule
啟用ngx_http_image_filter_module支持,傳輸JPEG\GIF\PNG圖片的一個過濾器,默認不啟用,需要安裝gd庫。 -
--with-http_geoip_module
啟用ngx_http_geoip_module支持,用于創(chuàng)建基于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創(chuàng)建集合,COPY和MOVE方法,默認為關閉,需要編譯開啟。 -
--with-http_flv_module
啟用ngx_http_flv_module支持,提供尋求內(nèi)存使用基于時間的偏移量文件。 -
--with-http_mp4_module
啟用ngx_http_mp4_module支持,啟用對mp4類視頻文件的支持。 -
--with-http_gzip_static_module
啟用ngx_http_gzip_static_module支持,支持在線實時壓縮輸出數(shù)據(jù)流。 -
--with-http_random_index_module
啟用ngx_http_random_index_module支持,從目錄中隨機挑選一個目錄索引。 -
--with-http_secure_link_module
啟用ngx_http_secure_link_module支持,計算和檢查要求所需的安全鏈接網(wǎng)址。 -
--with-http_degradation_module
啟用ngx_http_degradation_module 支持允許在內(nèi)存不足的情況下返回204或444代碼。 -
--with-http_stub_status_module
啟用ngx_http_stub_status_module 支持查看nginx的狀態(tài)頁。 -
--without-http_charset_module
禁用ngx_http_charset_module這一模塊,可以進行字符集間的轉(zhuǎn)換,從其它字符轉(zhuǎn)換成UTF-8或者從UTF8轉(zhuǎn)換成其它字符。它只能從服務器到客戶端方向,只有一個字節(jié)的字符可以轉(zhuǎn)換。 -
--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支持,該模塊用來確定客戶端后續(xù)請求的cookies。 -
--without-http_access_module
禁用ngx_http_access_module支持,提供了基于主機ip地址的訪問控制功能。 -
--without-http_auth_basic_module
禁用ngx_http_auth_basic_module支持,可以使用用戶名和密碼認證的方式來對站點或部分內(nèi)容進行認證。 -
--without-http_autoindex_module
禁用ngx_http_authindex_module,該模塊用于在ngx_http_index_module模塊沒有找到索引文件時發(fā)出請求,用于自動生成目錄列表。 -
--without-http_geo_module
禁用ngx_http_geo_module支持,這個模塊用于創(chuàng)建依賴于客戶端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,并且根據(jù)變量來轉(zhuǎn)向以及選擇配置。如果在server級別設置該選項,那么將在location之前生效,但如果location中還有更進一步的重寫規(guī)則,location部分的規(guī)則依然會被執(zhí)行。如果這個URI重寫是因為location部分的規(guī)則造成的,那么location部分會再次被執(zhí)行作為新的URI,這個循環(huán)會被執(zhí)行10次,最后返回一個500錯誤。 -
--without-http_proxy_module
禁用ngx_http_proxy_module支持,http代理功能。 -
--without-http_fastcgi_module
禁用ngx_http_fastcgi_module支持,該模塊允許nginx與fastcgi進程交互,并通過傳遞參數(shù)來控制fastcgi進程工作。 -
--without-http_uwsgi_module
禁用ngx_http_uwsgi_module支持,該模塊用來使用uwsgi協(xié)議,uwsgi服務器相關。 -
--without-http_scgi_module
禁用ngx_http_scgi_module支持,類似于fastcgi,也是應用程序與http服務的接口標準。 -
--without-http_memcached_module
禁用ngx_http_memcached支持,用來提供簡單的緩存,提高系統(tǒng)效率。 -
--without-http_limit_conn_module
禁用ngx_http_limit_conn_module支持,該模塊可以根據(jù)條件進行會話的并發(fā)連接數(shù)進行限制。 -
--without-http_limit_req_module
禁用ngx_limit_req_module支持,該模塊可以實現(xiàn)對于一個地址進行請求數(shù)量的限制。 -
--without-http_empty_gif_module
禁用ngx_http_empty_gif_module支持,該模塊在內(nèi)存中常駐了一個1*1的透明gif圖像,可以被非常快速的調(diào)用。 -
--without-http_browser_module
禁用ngx_http_browser_mdoule支持,創(chuàng)建依賴于請求報頭的值 。如果瀏覽器為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調(diào)用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協(xié)議。 -
--without-mail_iamp_module
禁用iamp協(xié)議。 -
--without-mail_smtp_module
禁用smtp協(xié)議。 -
--with-google_perftools_module
啟用ngx_google_perftools_mdoule支持,調(diào)試用,可以用來分析程序性能瓶頸。 -
--with-cpp_test_module
啟用ngx_cpp_test_module支持。 -
--add-module=
指定外部模塊路徑,啟用對外部模塊的支持。 -
--with-cc=
指向C編譯器路徑。 -
--with-cpp=
指向C預處理路徑。 -
--with-cc-opt=
設置C編譯器參數(shù),指定--with-cc-opt="-I /usr/lcal/include",如果使用select()函數(shù),還需要同時指定文件描述符數(shù)量--with-cc-opt="-D FD_SETSIZE=2048"。 (PCRE庫) -
--with-ld-opt=
設置連接文件參數(shù),需要指定--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庫設置附加參數(shù) 。 -
--with-md5=
指向md5庫文件目錄。 -
--with-md5-opt=
編譯時為md5庫設置附加參數(shù)。 -
--with-md5-asm
使用md5匯編源。 -
--with-sha1=
指向sha1庫文件目錄。 -
--with-sha1-opt=
編譯時為sha1庫設置附加參數(shù)。 -
--with-sha1-asm
使用sha1匯編源。 -
--with-zlib=
指向zlib庫文件目錄。 -
--with-zlib-opt=
在編譯時為zlib設置附加參數(shù)。 -
--with-zlib-asm=
為指定的CPU使用匯編源進行優(yōu)化。 -
--with-libatomic
為原子內(nèi)存的更新操作的實現(xiàn)提供一個架構。 -
--with-libatomic=
指向libatomic_ops的安裝目錄。 -
--with-openssl=
指向openssl安裝目錄。 -
--with-openssl-opt=
在編譯時為openssl設置附加參數(shù)。 -
--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 | 禁用 |