- 下载地址
- 安装编译环境
yum -y install gcc automake autoconf libtool make
- 一般我们都需要先装zlib,OpenSSL,PCRE
前者为了重写rewrite,openssl是https需要,后者为了gzip压缩。可以选择下载源码或者使用yum install pcre zlib openssl
安装,如果是下载源码安装,以pcre 为例:
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
tar -zxvf pcre-8.35.tar.gz
# 进入安装包目录
cd pcre-8.35
# 编译安装
./configure
make && make install
tar -zxvf nginx-${version}.tar.gz
cd nginx-${version}.tar.gz
./configure
make && make install
--prefix=<PATH> NGINX文件的目录,以及由其他configure脚本选项(不包括库的路径)设置的所有相对路径的基本位置以及nginx.conf配置文件的路径。默认值:/ usr / local / nginx。
--sbin-path=<PATH> NGINX可执行文件的名称,仅在安装期间使用。默认值:<prefix> / sbin / nginx
--conf-path=<PATH> NGINX配置文件的名称。但是,您可以通过在nginx命令行上使用选项指定其他文件来始终在启动时覆盖此值。默认值:<prefix> conf / nginx.conf-c <FILENAME>
--pid-path=<PATH> nginx.pid文件的名称,用于存储nginx主进程的进程ID 。安装后,可以使用NGINX配置文件中的pid指令更改文件名的路径。默认值:<prefix> /logs/nginx.pid
--error-log-path=<PATH> 错误,警告和诊断数据的主日志文件的名称。安装后,可以使用NGINX配置文件中的error_log指令更改文件名。默认值:<prefix> /logs/error.log
--http-log-path=<PATH> HTTP服务器请求的主日志文件的名称。安装后,始终可以使用NGINX配置文件中的access_log指令更改文件名。默认值:<prefix> /logs/access.log
--user=<NAME> NGINX工作进程使用其凭据的非特权用户的名称。安装后,可以使用NGINX配置文件中的user指令更改名称。默认:nobody
--group=<NAME> NGINX工作进程使用其凭据的组的名称。安装后,可以使用NGINX配置文件中的user指令更改名称。默认值:--user选项设置的值。
--with-pcre=<PATH> PCRE库源代码的路径,这是位置指令和Rewrite模块中正则表达式支持所必需的。
--with-pcre-jit 使用“即时编译”支持(pcre_jit指令)构建PCRE库。
--with-zlib=<PATH> zlib库的源代码路径,Gzip模块需要该路径。
- 默认构建的模块,如果想禁用,可以在configure中加入参数:
--without-<MODULE-NAME>
来禁用它
http_access_module 接受或拒绝来自指定客户端地址的请求。
http_auth_basic_module 通过使用HTTP基本身份验证协议验证用户名和密码来限制对资源的访问。
http_autoindex_module 处理以正斜杠字符(/)结尾的请求,并生成目录列表。
http_browser_module 创建其值取决于User-Agent请求标头值的变量。
http_charset_module 将指定的字符集添加到Content-Type响应标头。可以将数据从一个字符集转换为另一个字符集
http_empty_gif_module 发出单像素透明GIF。
http_fastcgi_module 将请求传递给FastCGI服务器。
http_geo_module 使用取决于客户端IP地址的值创建变量。
http_gzip_module 使用gzip压缩响应,将传输数据量减少一半或更多。
http_limit_conn_module 限制每个定义密钥的连接数,特别是来自单个IP地址的连接数。
http_limit_req_module 限制每个定义密钥的请求处理速率,特别是来自单个IP地址的请求的处理速率。
http_map_module 创建其值取决于其他变量值的变量。
http_memcached_module 将请求传递给memcached服务器。
http_proxy_module 将HTTP请求传递给另一台服务器。
http_referer_module 在Referer标头中阻止具有无效值的请求。
http_rewrite_module 使用正则表达式更改请求URI并返回重定向; 有条件地选择配置。需要PCRE库。
http_scgi_module 将请求传递给SCGI服务器。
http_ssi_module 在通过它的响应中处理SSI(服务器端包含)命令。
http_split_clients_module 创建适合A / B测试的变量,也称为拆分测试。
http_upstream_hash_module 启用通用哈希负载平衡方法。
http_upstream_ip_hash_module 启用IP哈希负载平衡方法。
http_upstream_keepalive_module 启用keepalive连接。
http_upstream_least_conn_module 启用最少连接负载平衡方法。
http_upstream_zone_module 启用共享内存区域。
http_userid_module 设置适合客户端识别的cookie。
http_uwsgi_module 将请求传递给uwsgi服务器。
--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_geoip_module 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_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_image_filter_module 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_mp4_module Provides pseudo-streaming server-side support for MP4 files.
-- with-http_perl_module 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_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_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.
-- with-http_sub_module Modifies a response by replacing one specified string by another.
-- with-http_xslt_module 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-http_v2_module Enable support for HTTP/2. See The HTTP/2 Module in NGINX on the NGINX blog for details.
-- with-mail Enables mail proxy functionality. To compile as a separate dynamic module instead, change the option to --with-mail=dynamic.
-- 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 Enables the TCP and UDP proxy functionality. To compile as a separate dynamic module instead, change the option to --with-stream=dynamic.
-- 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.