nginx 编译安装
===================html
编译自:
http://nginx.org/en/docs/install.htmlnginx
若是须要特别的 nginx 功能,可进行编译安装:正则表达式
源码包中提供 configure 脚本用于编译前定义 nginx 各方面的配置。
执行 configure 脚本最后生成 Makefile,make 命令根据 Makefile 进行编译安装。bash
configure 命令支持以下参数:this
--prefix=path 定义 nginx 文件的安装路径。 configure 的其余选项若是使用相对路径,那么以此路径为基础路径。(except for paths to libraries sources)。nginx.conf 文件中的相对路径也以此为基础路径。 默认 --prefix=/usr/local/nginx --sbin-path=path 设置 nginx 二进制程序的路径名,这个名字只在安装期间使用。 默认 --sbin-path=prefix/sbin/nginx --conf-path=path 设置 nginx.conf 的路径。 nginx 可在启动时手动以 -c file 参数指定其余配置文件。 默认 --conf-path=prefix/conf/nginx.conf --pid-path=path 设置 nginx.pid 文件的路径。安装nginx以后,可在 nginx.conf 文件中使用 pid 指令修改该路径。 默认 --pid-path=prefix/logs/nginx.pid --error-log-path=path 设置 nginx 错误日志的路径。安装nginx以后,可在 nginx.conf 文件中使用 error_log 指令修改该路径。 默认 --error-log-path=prefix/logs/error.log. --http-log-path=path 设置 nginx 访问日志的路径。安装nginx以后,可在 nginx.conf 文件中使用 access_log 指令修改该路径。 默认 --http-log-path=prefix/logs/access.log --user=name 设置启动 worker 进程时所使用的非特权用户名。安装nginx以后,可在 nginx.conf 文件中使用 user 指令修改用户名。 默认 --user=nobody --group=name 设置启动 worker 进程时所使用的非特权用户组名。安装nginx以后,可在 nginx.conf 文件中使用 group 指令修改用户组名。 默认 --group=nobody --with-select_module --without-select_module 是否编译 select 模块。使用 select 模块可以使 nginx 工做于 select() 模式。 若是 nginx 不支持其余更合适的模块,如 kqueue, epoll 或者 /dev/poll,该模块被自动编译。 --with-poll_module --without-poll_module 是否编译 poll 模块。使用 poll 模块可以使 nginx 工做于 poll() 模式。 若是 nginx 不支持其余更合适的模块,如 kqueue, epoll 或者 /dev/poll,该模块被自动编译。 --without-http_gzip_module 不编译 gzip 压缩模块。压缩模块用于压缩 HTTP 响应报文。该模块的编译和运行依赖 zlib 库。 --without-http_rewrite_module 不编译 rewrite 模块。rewrite 模块用于重定向 HTTP 请求,也能够改写 HTTP 请求的 URI。 该模块的编译和运行依赖 PCRE 库。 --without-http_proxy_module 不编译 proxy 模块。 --with-http_ssl_module 编译 ssl 模块。ssl 模块使 nginx 支持 HTTPs 协议。该模块默认不编译。 该模块的编译和运行依赖 OpenSSL 库。 --with-pcre=path 设置 PCRE 库的源码路径。首先须要下载和解压 PCRE 库:http://www.pcre.org。 要求 PCRE 的版本范围为 4.4 — 8.38。 设置以后,其他的就交给 ./configure 和 make 命令。 nginx 使用 PCRE 库用于支持正则表达式。正则表达式在 location 指令和 rewrite 模块中会用到。 --with-pcre-jit 编译 PCRE 库时,加入 “just-in-time compilation” 支持 (1.1.12, the pcre_jit directive) --with-zlib=path 设置 zlib 库的源码路径。首先须要下载和解压 zlib 库:http://zlib.net 要求 zlib 库的版本范围为 1.1.3 — 1.2.8 设置以后,其他的就交给 ./configure 和 make 命令。 gzip 压缩模块依赖 zlib 库。 --with-cc-opt=parameters 为 CFLAGS 变量设置额外的参数。 好比 FreeBSD 下使用 PCRE 库,必须指定 --with-cc-opt="-I /usr/local/include" 好比 但愿增长 select() 支持的文件数,可指定:--with-cc-opt="-D FD_SETSIZE=2048" --with-ld-opt=parameters 设置连接时的额外参数。 好比,FreeBSD 使用 PCRE 库时,必须指定 --with-ld-opt="-L /usr/local/lib"。
Example of parameters usage (all of this needs to be typed in one line):.net
./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-8.38 --with-zlib=../zlib-1.2.8
配置完成后,使用 make 命令编译安装 nginx。日志