nginx编译安装基本参数和模块介绍

一、实验环境介绍

linux发型版本:CentOS 6.9 x86_64
nginx源码包:nginx-1.14.1.tar.gz

[root@vir-rs2 opt]# ls -l /opt/nginx-1.14.1.tar.gz 
-rw-r--r-- 1 root root 1014040 Nov 12  2018 /opt/nginx-1.14.1.tar.gz
[root@vir-rs2 opt]# cat /etc/redhat-release 
CentOS release 6.9 (Final)
[root@vir-rs2 opt]# uname -r
2.6.32-696.el6.x86_64
[root@vir-rs2 opt]# uname -a
Linux vir-rs2 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:29:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

二、nginx的configure配置参数

2.1、获取configure帮助参数的帮助信息

官方文档参考路径:
https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#sources
http://nginx.org/en/docs/configure.html

命令行通过内建选项查看帮助信息:

[root@vir-rs2 opt]# ls
nginx-1.14.1.tar.gz
[root@vir-rs2 opt]# touch nginx-1.14.1.tar.gz 
[root@vir-rs2 opt]# clear
[root@vir-rs2 opt]# tar -xf nginx-1.14.1.tar.gz 
[root@vir-rs2 opt]# cd nginx-1.14.1
[root@vir-rs2 nginx-1.14.1]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[root@vir-rs2 nginx-1.14.1]# ./configure --help

  --help                             print this message

  --prefix=PATH                      set installation prefix
  --sbin-path=PATH                   set nginx binary pathname
  --modules-path=PATH                set modules path
  --conf-path=PATH                   set nginx.conf pathname
  --error-log-path=PATH              set error log pathname
  --pid-path=PATH                    set nginx.pid pathname
  --lock-path=PATH                   set nginx.lock pathname

  --user=USER                        set non-privileged user for
                                     worker processes
  --group=GROUP                      set non-privileged group for
                                     worker processes

  --build=NAME                       set build name
  --builddir=DIR                     set build directory

  --with-select_module               enable select module
  --without-select_module            disable select module
  --with-poll_module                 enable poll module
  --without-poll_module              disable poll module

  --with-threads                     enable thread pool support

  --with-file-aio                    enable file AIO support

  --with-http_ssl_module             enable ngx_http_ssl_module
  --with-http_v2_module              enable ngx_http_v2_module
  --with-http_realip_module          enable ngx_http_realip_module
  --with-http_addition_module        enable ngx_http_addition_module
  --with-http_xslt_module            enable ngx_http_xslt_module
  --with-http_xslt_module=dynamic    enable dynamic ngx_http_xslt_module
  --with-http_image_filter_module    enable ngx_http_image_filter_module
  --with-http_image_filter_module=dynamic
                                     enable dynamic ngx_http_image_filter_module
  --with-http_geoip_module           enable ngx_http_geoip_module
  --with-http_geoip_module=dynamic   enable dynamic ngx_http_geoip_module
  --with-http_sub_module             enable ngx_http_sub_module
  --with-http_dav_module             enable ngx_http_dav_module
    --with-http_flv_module             enable ngx_http_flv_module
  --with-http_mp4_module             enable ngx_http_mp4_module
  --with-http_gunzip_module          enable ngx_http_gunzip_module
  --with-http_gzip_static_module     enable ngx_http_gzip_static_module
  --with-http_auth_request_module    enable ngx_http_auth_request_module
  --with-http_random_index_module    enable ngx_http_random_index_module
  --with-http_secure_link_module     enable ngx_http_secure_link_module
  --with-http_degradation_module     enable ngx_http_degradation_module
  --with-http_slice_module           enable ngx_http_slice_module
  --with-http_stub_status_module     enable ngx_http_stub_status_module

  --without-http_charset_module      disable ngx_http_charset_module
  --without-http_gzip_module         disable ngx_http_gzip_module
  --without-http_ssi_module          disable ngx_http_ssi_module
  --without-http_userid_module       disable ngx_http_userid_module
  --without-http_access_module       disable ngx_http_access_module
  --without-http_auth_basic_module   disable ngx_http_auth_basic_module
  --without-http_mirror_module       disable ngx_http_mirror_module
  --without-http_autoindex_module    disable ngx_http_autoindex_module
  --without-http_geo_module          disable ngx_http_geo_module
  --without-http_map_module          disable ngx_http_map_module
  --without-http_split_clients_module disable ngx_http_split_clients_module
  --without-http_referer_module      disable ngx_http_referer_module
  --without-http_rewrite_module      disable ngx_http_rewrite_module
  --without-http_proxy_module        disable ngx_http_proxy_module
  --without-http_fastcgi_module      disable ngx_http_fastcgi_module
  --without-http_uwsgi_module        disable ngx_http_uwsgi_module
  --without-http_scgi_module         disable ngx_http_scgi_module
  --without-http_grpc_module         disable ngx_http_grpc_module
  --without-http_memcached_module    disable ngx_http_memcached_module
  --without-http_limit_conn_module   disable ngx_http_limit_conn_module
  --without-http_limit_req_module    disable ngx_http_limit_req_module
  --without-http_empty_gif_module    disable ngx_http_empty_gif_module
  --without-http_browser_module      disable ngx_http_browser_module
  --without-http_upstream_hash_module
                                     disable ngx_http_upstream_hash_module
  --without-http_upstream_ip_hash_module
                                     disable ngx_http_upstream_ip_hash_module
  --without-http_upstream_least_conn_module
                                     disable ngx_http_upstream_least_conn_module
  --without-http_upstream_keepalive_module
                                     disable ngx_http_upstream_keepalive_module
  --without-http_upstream_zone_module
                                     disable ngx_http_upstream_zone_module

  --with-http_perl_module            enable ngx_http_perl_module
  --with-http_perl_module=dynamic    enable dynamic ngx_http_perl_module
  --with-perl_modules_path=PATH      set Perl modules path
  --with-perl=PATH                   set perl binary pathname

  --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-proxy-temp-path=PATH        set path to store
                                     http proxy temporary files
  --http-fastcgi-temp-path=PATH      set path to store
                                     http fastcgi temporary files
  --http-uwsgi-temp-path=PATH        set path to store
                                     http uwsgi temporary files
  --http-scgi-temp-path=PATH         set path to store
                                     http scgi temporary files

  --without-http                     disable HTTP server
  --without-http-cache               disable HTTP cache

  --with-mail                        enable POP3/IMAP4/SMTP proxy module
  --with-mail=dynamic                enable dynamic POP3/IMAP4/SMTP proxy module
  --with-mail_ssl_module             enable ngx_mail_ssl_module
  --without-mail_pop3_module         disable ngx_mail_pop3_module
  --without-mail_imap_module         disable ngx_mail_imap_module
  --without-mail_smtp_module         disable ngx_mail_smtp_module

  --with-stream                      enable TCP/UDP proxy module
  --with-stream=dynamic              enable dynamic TCP/UDP proxy module
  --with-stream_ssl_module           enable ngx_stream_ssl_module
  --with-stream_realip_module        enable ngx_stream_realip_module
  --with-stream_geoip_module         enable ngx_stream_geoip_module
  --with-stream_geoip_module=dynamic enable dynamic ngx_stream_geoip_module
  --with-stream_ssl_preread_module   enable ngx_stream_ssl_preread_module
  --without-stream_limit_conn_module disable ngx_stream_limit_conn_module
  --without-stream_access_module     disable ngx_stream_access_module
  --without-stream_geo_module        disable ngx_stream_geo_module
  --without-stream_map_module        disable ngx_stream_map_module
  --without-stream_split_clients_module
                                     disable ngx_stream_split_clients_module
  --without-stream_return_module     disable ngx_stream_return_module
  --without-stream_upstream_hash_module
                                     disable ngx_stream_upstream_hash_module
  --without-stream_upstream_least_conn_module
                                     disable ngx_stream_upstream_least_conn_module
   --without-stream_upstream_zone_module
                                     disable ngx_stream_upstream_zone_module

  --with-google_perftools_module     enable ngx_google_perftools_module
  --with-cpp_test_module             enable ngx_cpp_test_module

  --add-module=PATH                  enable external module
  --add-dynamic-module=PATH          enable dynamic external module

  --with-compat                      dynamic modules compatibility

  --with-cc=PATH                     set C compiler pathname
  --with-cpp=PATH                    set C preprocessor pathname
  --with-cc-opt=OPTIONS              set additional C compiler options
  --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

  --without-pcre                     disable PCRE library usage
  --with-pcre                        force PCRE library usage
  --with-pcre=DIR                    set path to PCRE library sources
  --with-pcre-opt=OPTIONS            set additional build options for PCRE
  --with-pcre-jit                    build PCRE with JIT compilation support

  --with-zlib=DIR                    set path to zlib library sources
  --with-zlib-opt=OPTIONS            set additional build options for zlib
  --with-zlib-asm=CPU                use zlib assembler sources optimized
                                     for the specified CPU, valid values:
                                     pentium, pentiumpro

  --with-libatomic                   force libatomic_ops library usage
  --with-libatomic=DIR               set path to libatomic_ops library sources

  --with-openssl=DIR                 set path to OpenSSL library sources
  --with-openssl-opt=OPTIONS         set additional build options for OpenSSL

  --with-debug                       enable debug logging                                   

2.2、configure配置参数注解

2.2.1、路径配置类参数

Parameter
Description
centered right-aligned
--prefix=<PATH> Directory for NGINX files, and the base location for all relative paths set by the other configure script options (excluding paths to libraries) and for the path to the nginx.conf configuration file. Default: /usr/local/nginx.
--sbin-path=<PATH> Name of the NGINX executable file, which is used only during installation. Default: <prefix>/sbin/nginx
--conf-path=<PATH> Name of the NGINX configuration file. You can, however, always override this value at startup by specifying a different file with the -c <FILENAME> option on the nginx command line. Default: <prefix>conf/nginx.conf
--pid-path=<PATH> Name of the nginx.pid file, which stores the process ID of the nginx master process. After installation, the path to the filename can be changed with the pid directive in the NGINX configuration file. Default: <prefix>/logs/nginx.pid
--error-log-path=<PATH> Name of the primary log file for errors, warnings, and diagnostic data. After installation, the filename can be changed with the the error_log directive in the NGINX configuration file. Default: <prefix>/logs/error.log
--http-log-path=<PATH> Name of the primary log file for requests to the HTTP server. After installation, the filename can always be changed with the access_log directive in the NGINX configuration file. Default: <prefix>/logs/access.log
--user=<NAME> Name of the unprivileged user whose credentials are used by the NGINX worker processes. After installation, the name can be changed with the user directive in the NGINX configuration file. Default: nobody
--group=<NAME> Name of the group whose credentials are used by the NGINX worker processes. After installation, the name can be changed with the user directive in the NGINX configuration file. Default: the value set by the –user option.
--with-pcre=<PATH> Path to the source for the PCRE library, which is required for regular expressions support in the location directive and the Rewrite module.
--with-pcre-jit Builds the PCRE library with “just-in-time compilation” support (the pcre_jit directive).
--with-zlib=<PATH> Path to the source for the zlib library, which is required by the Gzip module.

在这里插入图片描述

  1. --prefix=<PATH>
    默认值: /usr/local/nginx #这个目录
    指定nginx安装文件的目录,这个是一个基目录,是其他路径参数脚本的安装相对目录,不过除了库文件安装路径之外。具体请看下文。后边相对这个路径,会直接写成 <prefix> ;

  2. --sbin-path=<PATH>
    默认值: <prefix>/sbin/nginx #这是一个文件,nginx是可执行文件名称;
    指定nginx执行文件的名称;

  3. --conf-path=<PATH>
    默认值: <prefix>/conf/nginx.conf #这是一个文件,nignx的主配置文件
    指定nginx的配置文件名。即使编译时候指定了配置文件名,在启动的时候,可以通过 -c <FILENAME> 选项指定不同的配置文件;

  4. --pid-path=<PATH>
    默认值: <prefix>/logs/nginx.pid #这是一个文件
    pid文件名(nginx.pid),这个文件中记录了nginx的管理进程的进程id号。可以通过pid指令来改变这个文件名和指向路径;

  5. --error-log-path=<PATH>
    默认值:<prefix>/logs/error.log #这是一个文件
    错误,告警,诊断数据的主日志记录文件,俗称的"nginx的错误日志文件"。这个日志可以通过配置存储不止nginx的错误信息,还有警告、诊断信息都可以记录。可以通过error_log指令修改这个文件名和指向路径;

  6. --http-log-path=<PATH>
    默认值:<prefix>logs/access.log #这是一个文件
    记录http服务器请求的主要日志文件,俗称"nginx的访问日志文件"。可以通过access_log指令来修改这个文件名和指向路径;

  7. --user=<NAME>
    默认值: nobody
    指明nginx的运行的工作进程(worker process)的用户属主。可以通过user指令来修改;

  8. –group=<NAME>
    默认值: --user执行的参数
    指明nginx的运行的工作进程的属组。同样也可以通过user指令来修改;

  9. --with-pcre=<PATH>
    PCRE库的源代码展开路径。在nginx中location指令和Rewrite(重写)模块都要用到正则表达式,这个是perl正则表达式支持的标准库。
    location指令:
    https://nginx.org/en/docs/http/ngx_http_core_module.html?&_ga=2.210706384.439430167.1542676606-764556676.1535355784#location
    Rewrite模块:
    https://nginx.org/en/docs/http/ngx_http_rewrite_module.html?_ga=2.210706384.439430167.1542676606-764556676.1535355784
    我们通过是通过yum来安装(yum安装的路径是标准路径,通常不用额外指定这个编译参数):
    yum install pcre pcre-devel

  10. - -with-pcre-jit
    表面意思是:build PCRE with JIT compilation support
    pcre_jit on | off;
    这个指令是nginx 1.1.12版本引入的。
    Enables or disables the use of “just-in-time compilation” (PCRE JIT) for the regular expressions known by the time of configuration parsing.(pcre的即时编译特性)
    关于pcre jit,可以参考这两个链接说明:
    https://www.zhihu.com/question/19672491
    https://segmentfault.com/q/1010000000366720
    PCRE JIT can speed up processing of regular expressions significantly.(PCREJ JIT能很明显的加速正则表达式的处理)
    The JIT is available in PCRE libraries starting from version 8.20 built with the --enable-jit configuration parameter. When the PCRE library is built with nginx (–with-pcre=), the JIT support is enabled via the --with-pcre-jit configuration parameter.(pcre库8.2.0版本开始以及之后才支持JIT,所以一般yum安装的pcre库版本比较低,如果要用jit特性,需要编译源码包pcre),可以尝试一下这个特性,不过需要自行下载pcre源码包(8.2.0以及以上版本)编译安装。

  11. --with-zlib=<PATH>
    指明zlib库的源码展开路径。nginx的Gzip模块要用到。
    Gzip模块:
    https://nginx.org/en/docs/http/ngx_http_gzip_module.html?_ga=2.241686343.439430167.1542676606-764556676.1535355784

2.2.2、gcc相关配置类参数(选读)

在这里插入图片描述

(1) --with-cc-opt=""
CFLAGS变量添加额外的参数。在FreeBSD下使用系统PCRE库,该编译选项的值为:
–with-cc-opt="-I /usr/local/include". 默认的select()函数支持的文件打开数量是1024,如果要增加这个值,可以类似于以下指定:–with-cc-opt="-D FD_SETSIZE=2048".
一般生产非特殊环境,不要去设置这个。因为现在主流内核版本和比较稳定的内核版本都是2.6之后了,已经支持了比select更好的epoll模型。

(2) --with-ld-opt=""
指定链接时候的额外参数。当在FreeBSD下使用系统PCRE库时候,这个值为:
--with-ld-opt="-L /usr/local/lib"
#这个参数几乎不会手动设置,除非调优级别的工程师或者测试级别。

2.2.3、指定nginx连接处理方法配置类参数

在这里插入图片描述

(1) --with-select_module,–without-select_module
启用或者不启用允许nginx服务器使用select()方法的模块。如果nginx运行的平台不支持诸如queue,epoll或/dev/poll等方法时,这个模块会自动被编译(如果两个参数都不指定的话)。建议编译时候指定显式启用(–with-select_module)。
(2) --with-poll_module,–without-poll_module
启用或者不启用允许nginx服务器使用poll()方法的模块。如果nginx运行的平台不支持诸如queue,epoll或/dev/poll等方法时,这个模块会自动被编译(如果两个参数都不指定的话)。建议编译时候指定显式启用(–with-poll_module)。

ps:编译时建议加上--with-select_module和--with-poll_module,因为select()和poll()是基本的方法;

2.2.4、选择nginx的编译模块

  • 概要说明
    nginx由一系列功能特定功能的模块组成,这些模块由配置脚本和其他编译选项指定。
    一些模块默认是内建编译的,不需要在configure脚本中显式指定。如果你强制不想要这些默认的模块编译进来(非常不建议这样做),可以在configure的脚本配置参数中显式指定–without-<MODULE-NAME>;
    不是默认内建编译进来的模块以及其他第三方模块,必须要显式指定在configure的配置脚本中。一些模块要么在启动的时候静态的链接到nginx的程序,要么就是在配置文件中使用特定的指令动态载入。(简单来说,nginx的有些模块是支持动态装卸载的,有些在nginx启动的时候就直接静态加载了,不管是动态装卸载的模块还是启动时静态载入的模块,都要先编译进来)

  • nginx的默认编译模块说明

  • 以下表格中是默认编译进来的模块,如果要强制不编译进来,需要通过–without-<MODULE-NAME>来指定;

Module Name
Description
http_access_module Accepts or denies requests from specified client addresses.
http_auth_basic_module Limits access to resources by validating the user name and password using the HTTP Basic Authentication protocol.
http_autoindex_module Processes requests ending with the forward-slash character (/) and produces a directory listing.
http_browser_module Creates variables whose values depend on the value of the User-Agent request header.
http_charset_module Adds the specified character set to the Content-Type response header. Can convert data from one character set to another.
http_empty_gif_module Emits a single-pixel transparent GIF.
http_fastcgi_module Passes requests to a FastCGI server.
http_geo_module Creates variables with values that depend on the client IP address.
http_gzip_module Compresses responses using gzip, reducing the amount of transmitted data by half or more.
http_limit_conn_module Limits the number of connections per a defined key, in particular, the number of connections from a single IP address.
http_limit_req_module Limits the request processing rate per a defined key, in particular, the processing rate of requests coming from a single IP address.
http_map_module Creates variables whose values depend on the values of other variables.
http_memcached_module Passes requests to a memcached server.
http_proxy_module Passes HTTP requests to another server.
http_referer_module Blocks requests with invalid values in the Referer header.
http_rewrite_module Changes the request URI using regular expressions and return redirects; conditionally selects configurations. Requires the PCRE library.
http_scgi_module Passes requests to an SCGI server.
http_ssi_module Processes SSI (Server Side Includes) commands in responses passing through it.
http_split_clients_module Creates variables suitable for A/B testing, also known as split testing.
http_upstream_hash_module Enables the generic Hash load-balancing method.
http_upstream_ip_hash_module Enables the IP Hash load-balancing method.
http_upstream_keepalive_module Enables keepalive connections.
http_upstream_least_conn_module Enables the Least Connections load-balancing method.
http_upstream_zone_module Enables shared memory zones.
http_userid_module Sets cookies suitable for client identification.
http_uwsgi_module Passes requests to a uwsgi server.

1、http_access_module
默认是编译进ngx_http_accesss_module这个模块;这个模块主要是对客户端做访问控制,限制某某网段能够以及不能够访问,文档地址:
http://nginx.org/en/docs/http/ngx_http_access_module.html
非特殊情况,不要使用 --without-http_access_module,否则访问控制功能就无法做了,这个模块生产中用的概率非常大。
2、http_auth_basic_module
默认是编译进ngx_http_auth_basic_module这个模块;这个模块主要是对客户端访问的资源做限制,可以做http的基本认证。(用户名和密码认证),文档地址:
http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html
非特殊情况,不要使用 --without-http_auth_basic_module,否则http基本认证功能就无法用了,这个模对于一个完备的生产环境,基本都会用到,有时候会监控状态信息,需要对状态页面做访问认证;
3、http_autoindex_module
默认是编译进ngx_http_autoindex_module这个模块;这个模块主要请求中的URI如果是以一个"/"结尾,可以配置自动展开目录列表的内容(目录展开,需要用户对目录具有执行权限),在一些下载站点,这个模块是要用到的,因为下载站点,资源要展开给用户看。文档地址:
http://nginx.org/en/docs/http/ngx_http_autoindex_module.html
非特殊情况,不要使用 --without-http_autoindex_module。生产用到的概率,随着业务类型耳边话,不过这个功能有用,建议保持默认选项。
4、http_browser_module
默认是编译进ngx_http_browser_module这个模块;这个模块主要是根据HTTP请求报文中的"User-Agent"中值来控制用户不同浏览器识别的资源。新式浏览器,老式浏览器以及低版本的IE浏览器,这些浏览器兼容性都不一样。为了更好的用途体验和视觉效果,有时候这种设定特别重要,属于前端调优部分的内容,针对不同浏览器调整。文档地址:
http://nginx.org/en/docs/http/ngx_http_browser_module.html
目前我做运维没有用到,建议保持默认不动;
5、http_charset_module
默认是编译进ngx_http_charset_module 这个模块;这个模块主要是和字符集控制相关的,非常重要;文档地址:
http://nginx.org/en/docs/http/ngx_http_charset_module.html
生产用到的概率,100%。除非特殊情况,否则编译时不要使用 --without-http_charset_module
6、http_empty_gif_module
默认是编译进ngx_http_empty_gif_module这个模块;这个模块主要用来产生单像素(1x1)透明的gif图;官方解释原话如下:
The ngx_http_empty_gif_module module emits single-pixel transparent GIF.
文档地址:
http://nginx.org/en/docs/http/ngx_http_empty_gif_module.html
这个模块有什么作用呢,简单来说这个模块应用到站点有各种图像的相关的(现在几乎都有把,比如新浪,百度等)。这个返回的单像素的透明的gif格式的图,由于是但像素空间占用较小,而是nginx中的透明图是存储在内存区域中,比如有些站点要优化,网页返回空白,无法显示,直接把这种单像素的页面返回给用户,加载速度更快;
我工作中,没涉及到过,可能是业务量级比较小,这个可以不用编译进来也可以不用管。如果不要编译进来,就使用 --without-http_empty_gif_module。不过呢,没有编译进来,下次要用就用重新编译,所以如果你不确认你的业务模型是否用到这个模块,就保持官方预设,默认是编译进来的。

7、http_fastcgi_module
默认是编译进ngx_http_fastcgi_module这个模块;这个模块主要用来允许把请求代理给后端的FastCGI服务器。文档地址:
http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html
这个是很大概率用到的,因为工作中的站点肯定会有动态资源,而且php普及率比较高;
工作中的动态资源遵循2:8把法则,有20%的动态资源,有80%的静态资源,而且20%的动态资源中请求数据库的和不请求数据库的也遵循2:8法则,动态资源中请求数据库的占20%,不请求数据库的占80%,大概是这样一个概念。所以你不是做特别设定或测试,就不要使用 --without-http_fastcgi_module;

8、http_geo_module
默认是编译进ngx_http_geo_module这个模块;设置模块主要用来根据不同的来源客户端请求的ip地址创建设置不同的变量值;文档地址:
http://nginx.org/en/docs/http/ngx_http_geo_module.html
需要根据客户端的ip地址实际不同来做不同调度的业务可能要用到这个模块,请自行根据特定业务类型做编译控制,目前我没有用到过。感觉用到的概率有6层,如果是大型业务,和cdn部署业务等相关的,可能有更高概率。如若要去掉,加上编译参数 --without-http_geo_module即可。

9、http_gzip_module
默认编译进ngx_http_gzip_module这个模块;这个模块的作用主要是提供gzip方法,去压缩响应报文的数据大小;响应资源压缩后,据说大小非常可观,可能会减少一半甚至更多,这样会减少带宽的使用,不过压缩会带额外cpu的性能消耗。两个准则,要么以cpu占用换带宽占用,要么以带宽占用换cpu占用;文档地址:
http://nginx.org/en/docs/http/ngx_http_gzip_module.html
工作中几乎都会用到压缩,而且这个gzip压缩方法使用概率非常高,应该85%以上的业务都用到了。除非特殊情况,否则不建议使用 --without-http_gzip_module。

10、http_limit_conn_module
默认编译进ngx_http_limit_conn_module这个模块;这个模块的作用是用来做并发访问控制以及连接限制,常用于下载站点控制资源请求或者同一个ip地址同时的连接请求等;
文档地址:
http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html
也算常用的一个模块的;非特殊情况,不用使用 --without-http_limit_conn_module;

11、http_limit_req_module
默认编译进ngx_http_limit_req_module这个模块;这个模块的作用也是用来限定处理每个请求的速率;也常用于下载类型站点;
文档地址:
http://nginx.org/en/docs/http/ngx_http_limit_req_module.html
非特殊情况,不用使用 --without-http_limit_req_module;

12、http_map_module
默认编译进ngx_http_map_module这个模块;这个模块的作用主要是通过其他变量的值来创建变量;文档地址:
http://nginx.org/en/docs/http/ngx_http_map_module.html
这个模块的作用,感觉主要是要对自己的网站做精细控制。有点类似我们之前根据用户不同浏览器的类型自动请求不同的主页,比如现在手机有多种类型,可以根据不同的手机类型,让其访问不同的虚拟主机等。目前我没接触到,感觉使用概率不大。可以保持默认行为,尽量别使用 --without-http_map_module;

13、http_memcached_module
默认编译进ngx_http_memcached_module 这个模块;这个模块主要是和Memcached Server打交道的,如果确定业务模型使用memcached的概率不大,可以不用编译进这个模块;文档地址:
http://nginx.org/en/docs/http/ngx_http_memcached_module.html
不用编译进来设置: --without-http_memcached_module

14、http_proxy_module
默认编译进ngx_http_proxy_module这个模块;这个模块主要是与代理相关的,把请求代理给后端服务器,常用于反向代理,以及和负载均衡结合的场景,使用概率非常高。文档地址:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html
除非特殊情况,否则别使用 : --without-http_proxy_module;

15、http_referer_module
默认编译进ngx_http_referer_module这个模块;这个模块主要是做外链限制的,和首部的"Referer"这个属性的值有关系。可以做资源防盗链,可以节省服务器带宽等,属于比较重要的一个模块;文档地址:
http://nginx.org/en/docs/http/ngx_http_referer_module.html
除非特殊情况,否则别使用: --without-http_referer_module

16、http_rewrite_module
默认编译进ngx_http_rewrite_module这个模块;这个模块主要是与重写相关的,会用到PCRE正则表达式。属于比较重要和常用的一个模块;文档地址:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html
除非特殊情况,否则别使用: --without-http_rewrite_module

17、http_scgi_module
默认编译进ngx_http_scgi_module这个模块;这个模块主要是把请求代理个SCGI服务器;这个和FastCGI协议一样,涉及的模块,建议编译进来,SCGI这个是源于python社区。文档地址:
http://nginx.org/en/docs/http/ngx_http_scgi_module.html
除非特殊情况,否则别使用: --without-http_scgi_module

18、http_ssi_module
默认编译进ngx_http_ssi_module这个模块;这个模块目前有些指令目前还在开发。此模块主要用来处理服务端包含ssi文件。这个模块我不清楚,而且感觉应用概率不大。文档地址:http://www.nginx.cn/doc/standard/httpssi.html
官网原注解:
The ngx_http_ssi_module module is a filter that processes SSI (Server Side Includes) commands in responses passing through it. Currently, the list of supported SSI commands is incomplete.
如果要取消编译: --without-http_ssi_module

19、http_split_clients_module
默认编译进ngx_http_split_clients_module这个模块;此模块的作用主要是支持用来创建变量来做A/B测试(分离测试);文档地址:
http://nginx.org/en/docs/http/ngx_http_split_clients_module.html
我没用过这个模块,就其功能而言貌似可以实施压力分离以及测试的机制,感觉用到的概率60%,可以默认保持编译进来。如果要取消编译: --without-http_split_clients_module

20、http_upstream_hash_module
这个不涉及到具体的模块,不过它提供了负载均衡中用到的hash方法,很重要。用到概率非常高,特别是和负载均衡打交道的。关于hash文档地址:
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#hash

21、http_upstream_ip_hash_module
这个不涉及到具体的模块,不过它提供了负载均衡中用到的ip_hash方法,很重要。用到概率非常高,特别是和负载均衡打交道的。关于ip_hash文档地址:
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#ip_hash

22、http_upstream_keepalive_module
这个不涉及到具体的模块,不过它提供了负载均衡应用中关于连接缓存的控制相关属性。关于连接缓存的文档地址如下:
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive

23、http_upstream_least_conn_module
这个不涉及到具体的模块,不过它提供了负载均衡中的least_conn方法,关于least_conn的文档地址:
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#least_conn

24、http_upstream_zone_module
这个不涉及到具体的模块,不过和负载均衡有关系,启用共享内存区域;关于zone的文档地址:
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#zone

25、http_userid_module
默认编译进ngx_http_userid_module这个模块;这个模块主要与客户端连接的cookie相关,为客户端的身份识别设置相应的cookies。很重要的模块,我没用到过,不过与cookies相关的东西都重要;文档地址:
http://nginx.org/en/docs/http/ngx_http_userid_module.html

26、http_uwsgi_module
默认编译进ngx_http_uwsgi_module这个模块;这个模块主要是把连接请求代理给uwscgi主机。和ngx_http_scgi_module,ngx_http_fastcgi_module一样,这个模块也重要。建议把这三个模块编译进来,默认形式亦是如此。

  • 引入nginx默认不包含的模块

默认没有编译进来的模块,且不支持动态编译的有:
|

Module Name
Description
--with-cpp_test_module Tests the C++ compatibility of header files.
--with-debug Enables the debugging log.
--with-file-aio Enables asynchronous I/O.
--with-google_perftools_module Allows using Google Performance tools library.
--with-http_addition_module Adds text before and after a response.
--with-http_auth_request_module Implements client authorization based on the result of a subrequest.
--with-http_dav_module Enables file management automation using the WebDAV protocol.
--with-http_degradation_module Allows returning an error when a memory size exceeds the defined value.
--with-http_flv_module Provides pseudo-streaming server-side support for Flash Video (FLV) files.
--with-http_gunzip_module Decompresses responses with Content-Encoding: gzip for clients that do not support the zip encoding method.
--with-http_gzip_static_module Allows sending precompressed files with the .gz filename extension instead of regular files.
--with-http_mp4_module Provides pseudo-streaming server-side support for MP4 files.
--with-http_random_index_module Processes requests ending with the slash character (‘/’) and picks a random file in a directory to serve as an index file.
--with-http_realip_module Changes the client address to the one sent in the specified header field.
--with-http_secure_link_module Used to check authenticity of requested links, protect resources from unauthorized access, and limit link lifetime.
--with-http_slice_module Allows splitting a request into subrequests, each subrequest returns a certain range of response. Provides more effective caching of large files.
--with-http_ssl_module Enables HTTPS support. Requires an SSL library such as OpenSSL.
--with-http_sub_module Modifies a response by replacing one specified string by another.
--with-http_v2_module Enable support for HTTP/2. See The HTTP/2 Module in NGINX on the NGINX blog for details.
--with-mail_ssl_module Provides support for a mail proxy server to work with the SSL/TLS protocol. Requires an SSL library such as OpenSSL.
--with-stream_ssl_module Provides support for a stream proxy server to work with the SSL/TLS protocol. Requires an SSL library such as OpenSSL.
--with-threads Enables NGINX to use thread pools. For details, see Thread Pools in NGINX Boost Performance 9x! on the NGINX blog.
--with-http_stub_status_module Provides access to basic status information. Note that NGINX Plus customers do not require this module as they are already provided with extended status metrics and interactive dashboard.

上面这些选项或选项涉及的模块是收录进nginx官方的非内置编译模块,可以在configure的显式加入上边的这些选项。上面这些选项对应的模块暂时不支持动态编译进来,也就是不支持模块的动态装卸载。其对应含义为:
1、--with-cpp_test_module
测试头文件对C++的兼容性;感觉用的很少,可以不用指定;

2、--with-debug
启用调试日志;生产环境不会用,可以不用指定;关于调试相关的文档地址:http://nginx.org/en/docs/debugging_log.html

3、--with-file-aio
启用FreeBSE和linux的异步IO;(AIO)
异步IO一致是追求的一种比较高性能的模型,可以编译进来。关于AIO文档地址:
http://nginx.org/en/docs/http/ngx_http_core_module.html#aio

4、--with-google_perftools_module
涉及相关的模块为ngx_google_perftools_module,如果要想使用该模块,要显式指定这个选项,这个模块主要是为了nginx的开发者提供的,它主要是通过google的高性能工具来对nginx的工作进程做压测绘图等。关于用到的google的高性能工具的链接:https://github.com/gperftools/gperftools
ngx_google_perftools_module模块文档地址:
http://nginx.org/en/docs/ngx_google_perftools_module.html
生产环境不要编译进来此模块;

5、--with-http_addition_module
涉及相关的模块为ngx_http_addition_module ,默认没有编译进来,如果要编译,请指定这栏的选项。这个模块主要是在发送响应报文前后,增加说明性内容;作为要精细控制响应报文的业务,可以把这个模块编译进来。模块文档地址:
http://nginx.org/en/docs/http/ngx_http_addition_module.html

6、--with-http_auth_request_module
涉及相关的模块为ngx_http_auth_request_module,默认没有编译进来。如果要编译进来,要指定这栏的选项。这个模块主要实现基于子请求的结果进行授权认证。比如我自己通过第三方程序或应用实现一个认证机制,然后去配置连接到后端主机,如果通过了第三方程序的认证,通过,返回的响应状态码应该是正常的,所以表示认证通过,没有通过状态码是异常的,所以没有通过我们的认证。这个模块表示通过把请求代理到后端认证主机,然后通过返回状态码来判断认证是否通过,有些场景会用到。
模块文档地址:
http://nginx.org/en/docs/http/ngx_http_auth_request_module.html

7、--with-http_dav_module
涉及相关的模块为ngx_http_dav_module,默认没有编译进来。如果要编译进来,要指定这栏的选项。这个模块主要是通过HTTP/1.1之后的一种新的叫做WebDAV 的协议来实现文件系统上文件的自动管理。既然实现了文件系统的文件的自动管理,那么相较传统支持的方法肯定有补充。
支持的方法有:PUT, DELETE, MKCOL, COPY, and MOVE
可以自动创建文件,控制创建文件的权限,可以指定对应层级目录下文件是否可以删除,移动等,并支持写文件锁定(Locking)及解锁(Unlock)。而且还支持文件的版本控制。该模块的文档地址:
http://nginx.org/en/docs/http/ngx_http_dav_module.html
这个模块听起来挺高大上的,不过文件通过web的自动管理相对来说安全隐患也会加大。只能说自动管理这个概念挺好,这个模块是否编译进来使用,每个人有每个的看法,这里没有使用经验,建议测试环境可以玩一下,生产环境还是别编译进来。

8、--with-http_degradation_module
抱歉,这个模块官方没有找到详细注解,只有一句话解释:
enables building the ngx_http_degradation_module module. This module is not built by default.
以及
Allows returning an error when a memory size exceeds the defined value.
没找到说的ngx_http_degradation_module模块。大概意思是,如果超过定义的内存大小的值后会返回错误,网上大部分说返回的是204或444响应状态码,没有考究,操作请慎重。

9、--with-http_flv_module
涉及的模块为ngx_http_flv_module,默认没有编译进来。如果要编译进来,要指定这栏的选项。
这个模块为Flash视频(FLV)文件提供了伪流服务器端支持。大概和音频点播,视频点播,直播平台等相关的站点,该模块可以编译进来。
文档地址:
http://nginx.org/en/docs/http/ngx_http_flv_module.html

10、--with-http_gunzip_module
涉及的模块为ngx_http_gunzip_module,默认没有编译进来。如果要编译进来,要指定这栏的选项。这个模块主要是兼容性设计的,对于有些连接请求的客户端本身不支持gzip压缩方法,这个模块可以帮助处理响应,因为大部分传输的数据是为了节约带宽以及传输时候的IO,所以有做压缩处理,现在一般很少有浏览器不支持压缩方法,这个模块建议包含进来,有时候的确认会用到。文档地址:
http://nginx.org/en/docs/http/ngx_http_gunzip_module.html

11、--with-http_gzip_static_module
涉及的模块为ngx_http_gzip_static_module,默认没有编译进来,如果要编译进来,要指定这栏的选项。这个模块实现了资源预压缩发送功能,大概就是不是请求的时候压缩资源,而是发送事先压缩好的以.gz为后缀的压缩文件(大概意思是这样,如果我理解有错误,请帮忙指正,谢谢)。预压缩功能的优先级要大于动态压缩(ngx_http_gzip_module这个默认使用chunked分块的方式动态压缩数据)。文档地址:
http://nginx.org/en/docs/http/ngx_http_gzip_static_module.html

12、--with-http_mp4_module
涉及的模块为ngx_http_mp4_module,默认没有编译进来,如果要编译进来,要指定这栏的选项。这个模块和ngx_http_flv_module模块一样,实现的是mp4格式的伪流服务器。应用范围,也可以参考ngx_http_flv_module这个模块。建议同时编译进来或者同时都不编译进来。模块文档地址:
http://nginx.org/en/docs/http/ngx_http_mp4_module.html

13、--with-http_random_index_module
涉及的相关模块为ngx_http_random_index_module ,默认没有编译进来,如果要编译进来,要指定这栏的选项。这个模块大概意思就是,如果请求的URI,是以"/"结尾,那么会随机在文档路径下挑选一个文件作为响应的主页文件,因为这个模块ngx_http_random_index_module 的优先级要先于ngx_http_index_module(指明主页文件的),所以如果先配置了下面这个模块ngx_http_random_index_module的启用相关的指令,对应文档请求路径以/结尾,就会随机返回一个文件。
先说这种机制设计出来,是为了让用户更好的体验。不过有了对应主页模块,建议不要配置使用这个模块,就算编译进来了,也别启用,测试环境除外,可以配置体验一下。(可能涉及对应目录展开权限,具体以测试结果为准)。模块文档地址:
http://nginx.org/en/docs/http/ngx_http_index_module.html

14、--with-http_realip_module
涉及的模块为ngx_http_realip_module,默认没有编译进来,如果要编译进来,要指定这栏的选项。 当原始用户的请求经过代理(squid,proxy)转发之后,nginx接收到的请求的来源地址也就变成了该代理服务器的IP,于是乎nginx 就无法获取用户请求的真实IP地址了。
所以,一般我们会在Nginx之前的代理服务器中把请求的原始来源地址编码进某个特殊的HTTP请求头中,然后再在Nginx中把这个请求头中编码的地址恢复出来。这样Nginx中的后续处理阶段(包括Nginx背后的各种后端应用)就会认为这些请求直接来自那些原始的地址,代理服务器就仿佛不存在一样。ngx_realip模块正是用来处理这个需求的。可以把它编译进来,不过现在一般用nginx做反向代理服务器,nginx反向代理实现模块有其他机制把用户真实的ip返回给后端主机。
参考链接:
http://www.mamicode.com/info-detail-1728752.html
模块文档地址:
http://nginx.org/en/docs/http/ngx_http_realip_module.html

15、--with-http_secure_link_module
涉及的模块为ngx_http_secure_link_module,默认没有编译进来,如果要编译进来,要指定这栏的选项。建议编译进来,这个模块用途很大。主要是用来对请求连接来源合法性进行检查,保护未经授权访问,限制链接的声明周期等,可以用来做资源链接保护,防盗链等。有个与之类似的模块ngx_http_referer_module,不过两者的实现不同,而且应用方式也不通。理解起来有些难度,建议配合实际实例进行理解。模块文档地址:
http://nginx.org/en/docs/http/ngx_http_secure_link_module.html

16、--with-http_slice_module
涉及的模块为ngx_http_slice_module ,默认没有编译进来,如果要编译进来,要指定这栏的选项。建议编译进来,这个模块可以对大请求进行切割,感觉对于部分应用作用很大。这里找到一个注解,还可以,可以了解一下,参考链接地址:
https://www.linuxidc.com/Linux/2016-08/134569.htm
模块文档地址:
http://nginx.org/en/docs/http/ngx_http_slice_module.html

17、--with-http_ssl_module
涉及的模块为ngx_http_ssl_module,默认没有编译进来,一定要编译进来。现在走https协议几乎已经成为主流,特别是安全原因,全栈https等。这个模块主要是支持https协议。
模块文档地址:
http://nginx.org/en/docs/http/ngx_http_ssl_module.html

18、--with-http_sub_module
涉及的模块为ngx_http_sub_module,默认没有编译进来。建议编译进来。这个模块主要实现,可以实现修改指定响应报文的内容。模块文档地址:
http://nginx.org/en/docs/http/ngx_http_sub_module.html

19、--with-http_v2_module
涉及的模块为ngx_http_v2_module,默认没有编译进来。这个模块主要是实现支持HTTP/2版本,也是这个ngx_http_spdy_module模块的替代。ngx_http_v2_module这个模块可以考虑编译进来,可能将来会成为主流,目前HTTP/1.1还算是用的比较多。模块文档地址:
http://nginx.org/en/docs/http/ngx_http_v2_module.html

20、--with-mail_ssl_module
涉及的模块为ngx_mail_ssl_module,默认没有编译进来。这个模块是和邮件相关的,让邮件代理服务器支持SSL/TLS 协议;如果业务没有涉及的可能,不用编译进来。模块文档地址:
http://nginx.org/en/docs/mail/ngx_mail_ssl_module.html

21、--with-stream_ssl_module
涉及的模块为ngx_stream_ssl_module,默认没有编译进来。这个模块主要是实现连接stream的过程也支持SSL/TLS 协议;stream模块,用来实现四层协议的转发、代理或者负载均衡等。模块文档链接:
http://nginx.org/en/docs/stream/ngx_stream_ssl_module.html

22、--with-threads
没有涉及具体模块。这个选项主要是启用nginx使用线程池的功能支持。相关链接:
http://nginx.org/en/docs/ngx_core_module.html#thread_pool
https://www.nginx.com/blog/thread-pools-boost-performance-9x/?_ga=2.175568999.439430167.1542676606-764556676.1535355784

23、--with-http_stub_status_module
涉及的模块为ngx_http_stub_status_module。这个模块默认没有编译进来。这个模块一定要编译进来,这个模块提供了nginx状态页信息,对于监控以及探测站点压力和请求非常有用,如果要配置状态页访问,一定要基于认证访问,这样是为了保证安全。

默认没有编译进来的模块,且支持动态编译和静态编译的有:

Module Name
Description
--with-http_geoip_module

--with-http_geoip_module=dynamic
Enables creating variables whose values depend on the client IP address.The module uses MaxMind GeoIP databases. To compile as a separate dynamic module instead, change the option to --with-http_geoip_module=dynamic.
--with-http_image_filter_module

--with-http_image_filter_module=dynamic
Transforms images in JPEG, GIF, and PNG formats. The module requires the LibGD library. To compile as a separate dynamic module instead, change the option to --with-http_image_filter_module=dynamic.
--with-http_perl_module

--with-http_perl_module=dynamic
Used to implement location and variable handlers in Perl and insert Perl calls into SSI. Requires the PERL library. To compile as a separate dynamic module instead, change the option to --with-http_perl_module=dynamic.
--with-http_xslt_module

--with-http_xslt_module=dynamic
Transforms XML responses using one or more XSLT stylesheets. The module requires the Libxml2 and XSLT libraries. To compile as a separate dynamic module instead, change the option to --with-http_xslt_module=dynamic.
--with-mail

--with-mail=dynamic
Enables mail proxy functionality. To compile as a separate dynamic module instead, change the option to --with-mail=dynamic.
--with-stream

--with-stream=dynamic.
Enables the TCP and UDP proxy functionality. To compile as a separate dynamic module instead, change the option to --with-stream=dynamic.

以下六个可以支持动态编译进来的选项
1、--with-http_geoip_module或 --with-http_geoip_module=dynamic
官网原话:
enables building the ngx_http_geoip_module module that creates variables depending on the client IP address and the precompiled MaxMind databases.
大概意思是可以根据客户端的ip地址配合MaxMind数据库来创建相关变量。这个模块主要是和地图,地理位置,微信朋友圈附近查找等功能可能会用到。
所涉及的模块叫ngx_http_geoip_module,默认没有编译进来。
使用此模块,要提供 MaxMind GeoIP 这个库的支持。这个库的官方链接地址为:
https://dev.maxmind.com/geoip/legacy/downloadable/
模块文档地址为:http://nginx.org/en/docs/http/ngx_http_geoip_module.html
如果要配置使用,可以参考链接:
http://ju.outofmemory.cn/entry/16264

2、--with-http_image_filter_module或--with-http_image_filter_module=dynamic
涉及的模块为ngx_http_image_filter_module,这个模块主要是实现不同格式图片之间互相转换,支持的格式有:JPEG, GIF, PNG, and WebP 。
这个模块需要libgd库的支持,libgd官网链接为:https://libgd.github.io/
WebP 这个格式是nginx 1.11.6版本引入的新格式。如果要涉及这个格式,要编译libgd 支持WebP。

3、--with-http_perl_module或--with-http_perl_module=dynamic
涉及的模块为ngx_http_perl_module。模块功能还在开发,不要编译进来了,生产环境。
模块文档地址:
http://nginx.org/en/docs/http/ngx_http_perl_module.html

4、--with-http_xslt_module或--with-http_xslt_module=dynamic
涉及的模块为ngx_http_xslt_module。建议编译进来,这个模块需要libxml2和 libxslt 库的支持。
模块主要作用:
The ngx_http_xslt_module (0.7.8+) is a filter that transforms XML responses using one or more XSLT stylesheets. 好像是与表单格式转换相关的。模块文档地址:
http://nginx.org/en/docs/http/ngx_http_xslt_module.html

5、--with-mail或 --with-mail=dynamic
enables POP3/IMAP4/SMTP mail proxy server.
也是与邮件相关的选项,可以动态编译进来,启用POP3/IMP4/SMTP邮件代理服务器;
可以参考:
http://nginx.org/en/docs/mail/ngx_mail_core_module.html

6、--with-stream或--with-stream=dynamic
涉及的模块为ngx_stream_core_module。这个建议编译进来,可以动态编译进来。nginx通过这个模块来实现的TCP/UDP的4层代理以及负载均衡。之前nginx只支持7层代理,nginx 1.9.0版本之后,就引入的这个强大的功能。

  • 引入第三方模块
    nginx的第三方模块链接:
    https://www.nginx.com/resources/wiki/modules/?_ga=2.146084081.439430167.1542676606-764556676.1535355784
    编译进第三方模块,使用以下两个选项:
    --add-module=<PATH> #这个是静态编译进来
    --add-dynamic-module=<PATH> #这个是动态编译进来
    对于能动态编译进来的建议动态编译进来,因为可以支持模块的动态装载和卸载;
    这里的<PATH>指的是下载的第三方模块的源代码(c源代码)的解压目录,编译的时候不用编译,源代码解压后通过上面的选项指向即可,如果第三方模块有依赖库或者组件,要提前安装到系统环境上。

2.3、参考编译安装配置

#安装一些依赖库和组件
yum -y install autoconf automake gcc gcc-c++ zlib-devel zlib openssl-devel openssl pcre-devel pcre gd-devel gd libxml2-devel libxml2 libxslt-devel libxslt perl-devel perl-ExtUtils-Embed libatomic_ops-devel
#其中的Install_Dir变量可以设置成自己要想要安装路径。比如我这里设置
Install_Dir=/data/application
mkdir -pv $Install_Dir

#创建用户和组
groupadd nginx
useradd -M -s /sbin/nologin -g nginx nginx

#创建一些目录
mkdir -p ${Install_Dir}/nginx/client_body
mkdir -p ${Install_Dir}/nginx/proxy
mkdir -p ${Install_Dir}/nginx/uwsgi
mkdir -p ${Install_Dir}/nginx/fastcgi
mkdir -p ${Install_Dir}/nginx/scgi
mkdir -p /etc/nginx
mkdir -p /var/log/nginx
mkdir -p /var/run/nginx
mkdir -p /var/lock/nginx
#一份编译参考配置
./configure \
--prefix=${Install_Dir}/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/nginx.lock \
--user=nginx \
--group=nginx \
--with-select_module \
--with-poll_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_stub_status_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--with-http_perl_module=dynamic \
--with-mail=dynamic \
--with-mail_ssl_module \
--with-stream=dynamic \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_ssl_preread_module \
--with-pcre \
--with-libatomic \
--http-client-body-temp-path=${Install_Dir}/nginx/client_body/ \
--http-proxy-temp-path=${Install_Dir}/nginx/proxy/ \
--http-fastcgi-temp-path=${Install_Dir}/nginx/fastcgi/ \
--http-uwsgi-temp-path=${Install_Dir}/nginx/uwsgi \
--http-scgi-temp-path=${Install_Dir}/nginx/scgi \
&& make && make install


PS:更多关于nginx编译安装介绍,将于下次编写nginx专题时提供。[烟灰]

猜你喜欢

转载自blog.csdn.net/u012271055/article/details/84291170