1. 程式人生 > >Nginx編譯安裝及編譯參數講解

Nginx編譯安裝及編譯參數講解

支持 assembler 臨時文件 files sha cached erro mp4 工具

技術分享圖片
實驗環境說明:
操作系統:Centos 7 64位
Nginx版本:Nginx 1.12.2

編譯安裝前的準備
安裝Nginx編譯安裝需要依賴的一些包
yum install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel open openssl-devel -y

#Nginx的編譯安裝及編譯參數詳解

Nginx的編譯參數講解
--prefix=PATH set installation prefix #設置安裝路徑
--sbin-path=PATH set nginx binary pathname #設置binary 路徑
--conf-path=PATH set nginx.conf pathname #設置nginx 配置文件路徑

--error-log-path=PATH set error log pathname #設置錯誤日誌路徑
--pid-path=PATH set nginx.pid pathname #設置nginx.pid 路徑
--lock-path=PATH set nginx.lock pathname #設置nginx.lock路徑

--user=USER set non-privileged user for #設置沒有特殊權限的用戶執行worker processes
worker processes
--group=GROUP set non-privileged group for #設置沒有特殊權限的用戶執行worker processes

worker processes

--builddir=DIR set build directory #設置編譯目錄

--with-rtsig_module enable rtsig module #開啟rtsig 模塊
--with-select_module enable select module #開啟select 模塊
--without-select_module disable select module #關閉 select 模塊
--with-poll_module enable poll module #啟用 poll 模塊
--without-poll_module disable poll module #關閉poll 模塊

--with-file-aio enable file AIO support #開啟file AIO支持
--with-ipv6 enable IPv6 support #開啟IPv6 支持

--with-http_ssl_module enable ngx_http_ssl_module #開啟ssl 模塊
--with-http_spdy_module enable ngx_http_spdy_module #開啟spdy模塊
--with-http_realip_module enable ngx_http_realip_module #開啟 realip 模塊
--with-http_addition_module enable ngx_http_addition_module #開啟 addition 模塊
--with-http_xslt_module enable ngx_http_xslt_module #開啟 xslt模塊
--with-http_image_filter_module enable ngx_http_image_filter_module #開啟 image_filter模塊
--with-http_geoip_module enable ngx_http_geoip_module #開啟geoip模塊
--with-http_sub_module enable ngx_http_sub_module #開啟 sub模塊
--with-http_dav_module enable ngx_http_dav_module #開啟dav 模塊
--with-http_flv_module enable ngx_http_flv_module #開啟 flv模塊
--with-http_mp4_module enable ngx_http_mp4_module #開啟 mp4模塊
--with-http_gunzip_module enable ngx_http_gunzip_module #開啟gunzip模塊
--with-http_gzip_static_module enable ngx_http_gzip_static_module #開啟 gzip_static模塊
--with-http_auth_request_module enable ngx_http_auth_request_module #開啟 auth_request(身份驗證請求)模塊
--with-http_random_index_module enable ngx_http_random_index_module #開啟random_index(隨機指數)模塊
--with-http_secure_link_module enable ngx_http_secure_link_module #開啟 secure_link(安全鏈接)模塊
--with-http_degradation_module enable ngx_http_degradation_module #開啟degradation 模塊
--with-http_stub_status_module enable ngx_http_stub_status_module #開啟 stub_status 模塊

--without-http_charset_module disable ngx_http_charset_module #關閉 charset(字符集) 模塊
--without-http_gzip_module disable ngx_http_gzip_module #關閉 gzip模塊
--without-http_ssi_module disable ngx_http_ssi_module #關閉 ssi 模塊
--without-http_userid_module disable ngx_http_userid_module #關閉 userid模塊
--without-http_access_module disable ngx_http_access_module #關閉 access模塊
--without-http_auth_basic_module disable ngx_http_auth_basic_module #關閉 auth_basic (基本身份認證)模塊
--without-http_autoindex_module disable ngx_http_autoindex_module #關閉 autoindex(自動變址)模塊
--without-http_geo_module disable ngx_http_geo_module #關閉 geo模塊
--without-http_map_module disable ngx_http_map_module #關閉 map 模塊
--without-http_split_clients_module disable ngx_http_split_clients_module #關閉 split_clients (劃分客戶端)模塊
--without-http_referer_module disable ngx_http_referer_module #關閉 referer (推薦人)模塊
--without-http_rewrite_module disable ngx_http_rewrite_module #關閉 rewrite (重寫)模塊
--without-http_proxy_module disable ngx_http_proxy_module #關閉 proxy (代理)模塊
--without-http_fastcgi_module disable ngx_http_fastcgi_module #關閉 fastcgi模塊
--without-http_uwsgi_module disable ngx_http_uwsgi_module #關閉 uwsgi 模塊
--without-http_scgi_module disable ngx_http_scgi_module #關閉 scgi 模塊
--without-http_memcached_module disable ngx_http_memcached_module #關閉 memcached 模塊
--without-http_limit_conn_module disable ngx_http_limit_conn_module # 關閉 limit_conn 模塊
--without-http_limit_req_module disable ngx_http_limit_req_module #關閉 limit_req模塊
--without-http_empty_gif_module disable ngx_http_empty_gif_module #關閉 empty_gif 模塊
--without-http_browser_module disable ngx_http_browser_module #關閉 browser 模塊
--without-http_upstream_ip_hash_module
disable ngx_http_upstream_ip_hash_module #關閉 ip_hash模塊
--without-http_upstream_least_conn_module
disable ngx_http_upstream_least_conn_module #關閉 least_conn 模塊
--without-http_upstream_keepalive_module
disable ngx_http_upstream_keepalive_module #關閉 keepalive 模塊

--with-http_perl_module enable ngx_http_perl_module #開啟perl 模塊
--with-perl_modules_path=PATH set Perl modules path #設置perl模塊路徑
--with-perl=PATH set perl binary pathname #設置perl 命令路徑

--http-log-path=PATH set http access log pathname #設置訪問日誌 路徑
--http-client-body-temp-path=PATH set path to store
http client request body temporary files #設置存儲路徑 http客戶端請求主體臨時文件
--http-proxy-temp-path=PATH set path to store
http proxy temporary files #設置存儲路徑 http代理臨時文件
--http-fastcgi-temp-path=PATH set path to store
http fastcgi temporary files #設置 fastcgi臨時文件存儲路徑
--http-uwsgi-temp-path=PATH set path to store
http uwsgi temporary files #設置 uwsgi 臨時文件存儲路徑
--http-scgi-temp-path=PATH set path to store
http scgi temporary files #設置 scgi 臨時文件存儲路徑

--without-http disable HTTP server #關閉 http server
--without-http-cache disable HTTP cache #關閉 http cache

--with-mail enable POP3/IMAP4/SMTP proxy module #開啟 POP3/IMAP4/SMTP 協議模塊
--with-mail_ssl_module enable ngx_mail_ssl_module #開啟 nginx mail ssl 模塊
--without-mail_pop3_module disable ngx_mail_pop3_module #關閉 mail pop3模塊
--without-mail_imap_module disable ngx_mail_imap_module #關閉 mail imap 模塊
--without-mail_smtp_module disable ngx_mail_smtp_module #關閉 mail smtp 模塊

--with-google_perftools_module enable ngx_google_perftools_module #開啟 nginx google_perftools (谷歌性能工具)模塊
--with-cpp_test_module enable ngx_cpp_test_module #開啟 cpp_test 模塊

--add-module=PATH enable an external module #開啟external(外部)模塊

--with-cc=PATH set C compiler pathname #設置C 編譯器 路徑
--with-cpp=PATH set C preprocessor pathname #設置 C預編譯器 路徑
--with-cc-opt=OPTIONS set additional C compiler options #設置額外的C編譯器選項
--with-ld-opt=OPTIONS set additional linker options #設置額外的鏈接器選項
--with-cpu-opt=CPU build for the specified CPU, valid values:
pentium, pentiumpro, pentium3, pentium4,
athlon, opteron, sparc32, sparc64, ppc64 #建立指定的CPU 有效值:

--without-pcre disable PCRE library usage #關閉 PCRE 庫 使用
--with-pcre force PCRE library usage #強制使用指定的PCRE 庫
--with-pcre=DIR set path to PCRE library sources #指定 pcre 使用路徑
--with-pcre-opt=OPTIONS set additional build options for PCRE #為PCRE設置額外的構建選項
--with-pcre-jit build PCRE with JIT compilation support #構建PCRE JIT編譯的支持

--with-md5=DIR set path to md5 library sources #設置路徑md5庫資源
--with-md5-opt=OPTIONS set additional build options for md5 #為md5設置額外的構建選項
--with-md5-asm use md5 assembler sources #使用md5匯編源

--with-sha1=DIR set path to sha1 library sources #設置 sha1 庫的路徑
--with-sha1-opt=OPTIONS set additional build options for sha1 #為sha1設置額外的構建選項
--with-sha1-asm use sha1 assembler sources #使用sha1匯編源

--with-zlib=DIR set path to zlib library sources #指定 zlib 庫的路徑
--with-zlib-opt=OPTIONS set additional build options for zlib #為zlib 設置額外的構建選項
--with-zlib-asm=CPU use zlib assembler sources optimized
for the specified CPU, valid values:
pentium, pentiumpro #使用 zlib匯編優化的來源

--with-libatomic force libatomic_ops library usage #強制 使用libatomic
--with-libatomic=DIR set path to libatomic_ops library sources #設置 libatomic 路徑

--with-openssl=DIR set path to OpenSSL library sources #設置 openssl 庫的路徑
--with-openssl-opt=OPTIONS set additional build options for OpenSSL #為 openssl 設置額外的構建選項

--with-debug enable debug logging #開啟debug 日誌

Nginx的編譯步驟:
一、執行nginx源碼包中的configure腳本
解壓nginx的源碼包,進入nginx源碼包解壓後的目錄中,執行configure腳本,生成makefile文件。
我在生成makefile文件時,使用以下編譯參數
./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx --group=nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --with-debug

二、使用make命令和make install命令進行編譯安裝
make && make install

到此為止,我們我們的nginx程序就安裝好了。

Nginx編譯安裝及編譯參數講解