nginx編譯參數和示例

 

編譯參數

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

來自:http://www.howtocn.org/nginx:installoptions

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章