天天看點

Nginx編譯時參數

已收錄到http://www.qq-live.com/index.php?app=blog&id=3

configure決定系統的特性,以及nginx可以用來處理連接配接的某些特性和方法,最後它将建立Makefile。

configure支援以下選項:

–prefix=<path> – 安裝路徑,如果沒有指定,預設為/usr/local/nginx。

–sbin-path=<path> – nginx可執行指令的檔案,如果沒有指定,預設為<prefix>/sbin/nginx。

–conf-path=<path> – 在沒有使用-c參數指定的情況下nginx.conf的預設位置,如果沒有指定,預設為<prefix>/conf/nginx.conf。

–pid-path=<path> – nginx.pid的路徑,如果沒有在nginx.conf中通過“pid”指令指定,預設為<prefix>/logs/nginx.pid。

–lock-path=<path> – nginx.lock檔案路徑,如果沒有指定,預設為<prefix>/logs/nginx.lock。

–error-log-path=<path> – 當沒有在nginx.conf中使用“error_log”指令指定時的錯誤日志位置,如果沒有指定,預設為<prefix>/logs/error.log。

–http-log-path=<path> – 當沒有在nginx.conf中使用“access_log”指令指定時的通路日志位置,如果沒有指定,預設為<prefix>/logs/access.log。

–user=<user> – 當沒有在nginx.conf中使用“user”指令指定時nginx運作的使用者,如果沒有指定,預設為“nobody”。

–group=<group> – 當沒有在nginx.conf中使用“user”指令指定時nginx運作的組,如果沒有指定,預設為“nobody”。

–builddir=DIR – 設定建構目錄。

–with-rtsig_module – 啟用rtsig子產品。

–with-select_module –without-select_module – 如果在configure的時候沒有發現kqueue, epoll, rtsig或/dev/poll其中之一,select子產品始終為啟用狀态。

–with-poll_module –without-poll_module – 如果在configure的時候沒有發現kqueue, epoll, rtsig或/dev/poll其中之一,poll子產品始終為啟用狀态。

–with-http_ssl_module – 啟用ngx_http_ssl_module,啟用SSL支援并且能夠處理HTTPS請求。需要OpenSSL,在Debian系統中,對應的包為libssl-dev。

–with-http_realip_module – 啟用ngx_http_realip_module

–with-http_addition_module – 啟用ngx_http_addition_module

–with-http_sub_module – 啟用ngx_http_sub_module

–with-http_dav_module – 啟用ngx_http_dav_module

–with-http_flv_module – 啟用ngx_http_flv_module

–with-http_stub_status_module – 啟用”server status”(服務狀态)頁

–without-http_charset_module – 禁用ngx_http_charset_module

–without-http_gzip_module – 禁用ngx_http_gzip_module,如果啟用,需要zlib包。

–without-http_ssi_module – 禁用ngx_http_ssi_module

–without-http_userid_module – 禁用ngx_http_userid_module

–without-http_access_module – 禁用ngx_http_access_module

–without-http_auth_basic_module – 禁用ngx_http_auth_basic_module

–without-http_autoindex_module – 禁用ngx_http_autoindex_module

–without-http_geo_module – 禁用ngx_http_geo_module

–without-http_map_module – 禁用ngx_http_map_module

–without-http_referer_module – 禁用ngx_http_referer_module

–without-http_rewrite_module – 禁用ngx_http_rewrite_module。如果啟用,需要PCRE包。

–without-http_proxy_module – 禁用ngx_http_proxy_module

–without-http_fastcgi_module – 禁用ngx_http_fastcgi_module

–without-http_memcached_module – 禁用ngx_http_memcached_module

–without-http_limit_zone_module – 禁用ngx_http_limit_zone_module

–without-http_empty_gif_module – 禁用ngx_http_empty_gif_module

–without-http_browser_module – 禁用ngx_http_browser_module

–without-http_upstream_ip_hash_module – 禁用ngx_http_upstream_ip_hash_module

–with-http_perl_module – 啟用ngx_http_perl_module

–with-perl_modules_path=PATH – 為perl子產品設定路徑

–with-perl=PATH – 為perl庫設定路徑

–http-client-body-temp-path=PATH – 為http連接配接的請求實體臨時檔案設定路徑,如果沒有指定,預設為<prefix>/client_body_temp

–http-proxy-temp-path=PATH – 為http代理臨時檔案設定路徑,如果沒有指定,預設為<prefix>/proxy_temp

–http-fastcgi-temp-path=PATH - 為http fastcgi臨時檔案設定路徑,如果沒有指定,預設為<prefix>/fastcgi_temp

–without-http – 禁用HTTP服務

–with-mail – 啟用IMAP4/POP3/SMTP代理子產品

–with-mail_ssl_module – 啟用ngx_mail_ssl_module

–with-cc=PATH – 設定C編譯器路徑

–with-cpp=PATH – 設定C預處理器路徑

–with-cc-opt=OPTIONS – 變量CFLAGS中附加的參數,用于FreeBSD中的PCRE庫,同樣需要指定–with-cc-opt=”-I /usr/local/include”,如果我們使用select()函數則需要同時增加檔案描述符數量,可以通過–with-cc-opt=”-D FD_SETSIZE=2048”指定。

–with-ld-opt=OPTIONS – 通過連接配接器的附加參數,用于FreeBSD中的PCRE庫,同樣需要指定–with-ld-opt=”-L /usr/local/lib”。

–with-cpu-opt=CPU – 指定編譯的CPU,可用的值為: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64

–without-pcre – 禁用PCRE庫檔案,同時将禁用HTTP rewrite 子產品,如果要在”location”指令中使用正規表達式,同樣需要PCRE庫。

–with-pcre=DIR – 設定PCRE庫源檔案路徑。

–with-pcre-opt=OPTIONS – 在編譯時為PCRE設定附加參數。

–with-md5=DIR – 設定md5庫源檔案路徑。

–with-md5-opt=OPTIONS – 在編譯時為md5設定附加參數。

–with-md5-asm – 使用md5彙編源。

–with-sha1=DIR – 設定sha1庫源檔案路徑。

–with-sha1-opt=OPTIONS – 在編譯時為sha1設定附加參數。

–with-sha1-asm – 使用sha1彙編源。

–with-zlib=DIR – 設定zlib庫源檔案路徑。

–with-zlib-opt=OPTIONS – 在編譯時為zlib設定附加參數。

–with-zlib-asm=CPU – 為指定的CPU使用zlib彙編源進行優化,可用值為: pentium, pentiumpro。

–with-openssl=DIR – 設定openssl庫源檔案路徑。

–with-openssl-opt=OPTIONS – 在編譯時為openssl設定附加參數。

–with-debug – 啟用debug記錄。

–add-module=PATH – 增加一個在PATH中的第三方子產品。

編譯參數可能會根據版本的不同進行變化,可以使用./configure –help檢視編譯參數清單。

示例

示例1

./configure \
  --sbin-path=/usr/local/nginx/nginx \
  --conf-path=/usr/local/nginx/nginx.conf \
  --pid-path=/usr/local/nginx/nginx.pid \
  --with-http_ssl_module \
  --with-pcre=../pcre-4.4 \
  --with-zlib=../zlib-1.1.3      

示例2

./configure \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --pid-path=/var/run/nginx.pid \
  --lock-path=/var/lock/nginx.lock \
  --http-log-path=/var/log/nginx/access.log \
  --with-http_dav_module \
  --http-client-body-temp-path=/var/lib/nginx/body \
  --with-http_ssl_module \
  --http-proxy-temp-path=/var/lib/nginx/proxy \
  --with-http_stub_status_module \
  --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
  --with-debug \
  --with-http_flv_module      

示例3

用于基于RedHat的系統(RHEL, CentOS, Fedora)。

首先,安裝依賴包:

yum install gcc openssl-devel pcre-devel zlib-devel      

然後運作configure:

./configure \
  --prefix=/usr \
  --sbin-path=/usr/sbin/nginx \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --pid-path=/var/run/nginx/nginx.pid  \
  --lock-path=/var/lock/nginx.lock \
  --user=nginx \
  --group=nginx \
  --with-http_ssl_module \
  --with-http_flv_module \
  --with-http_gzip_static_module \
  --http-log-path=/var/log/nginx/access.log \
  --http-client-body-temp-path=/var/tmp/nginx/client/ \
  --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
  --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/      

最後編譯并安裝:

make && make install