为什么linux查看nginx版本的官方仓库里面没有主线版本

在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
官方仓库地址:官方下载页地址:问题:官方下载页显示主线版本是1.9.12,官方仓库里面没有,有个2.0系列,什么意思?
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
源码看这里:
希望有所帮助~ :)
分享到微博?
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:
在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。1、首先下载对应最新版nginx
http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2、然后就是建立yum仓库
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
3、卸载系统原有的旧版的nginx
yum remove nginx
4、下载安装nginx
yum install nginx
5、启动nginx
systemctl start nginx
阅读(...) 评论()nginx 安装详解(better version) - 简书
nginx 安装详解(better version)
选择 Stable 还是 Mainline?
选择预编译的 pacakge 还是从源码编译?
从源码编译 nginx
安装 nginx 的依赖库
下载源码 tarball
配置编译选项
配置 nginx 文件安装路径
配置 nginx gcc 选项
指定 nginx 并发模型
nginx 的模块
默认编译的模块
默认不编译的模块
第三方模块
静态链接模块和动态链接模块
安装预编译的 package
预编译的 package 所包含的模块
安装 Red Hat/CentOS packages
选择 Stable 还是 Mainline?
nginx 提供两种版本的源码包:
mainline 版。该版本包含最新的特性和bug修改,并且总是保持更新。该版本是可靠的,但它可能会包含实验性的模块,以及一定数量的新 bug。
stable 版。该版本不包含新特性,但包含关键 bug 修复。推荐使用该版用于生产环境。
选择预编译的 pacakge 还是从源码编译?
mainline 版和 stable 版都提供两种安装方式:
从预编译的 package 进行安装。这是快速和容易的安装方式。预编译的 package 包含几乎所有的 nginx 官方模块,且适用于大多数流行的操作系统。
从源码编译安装。这种方式更为灵活:你可以添加特定的模块,包含添加第三方的模块,或者应用最新的安全补丁。
从源码编译 nginx
从源码编译安装的方式更为灵活:你可以添加特定的模块,包含添加第三方的模块,或者应用最新的安全补丁。
安装 nginx 的依赖库
在编译安装 nginx 之前,需要首先安装 nginx 的依赖:
库 - nginx 的
模块依赖 PCRE 库。它提供对于正则表达式的支持:
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
$ tar -zxf pcre-8.38.tar.gz
$ cd pcre-8.38
$ ./configure
$ sudo make install
译注:也可用 yum install pcre-devel 替代
库 - nginx 的
模块依赖 zlib 库。用于对 HTTP headers 进行压缩:
$ wget http://zlib.net/zlib-1.2.8.tar.gz
$ tar -zxf zlib-1.2.8.tar.gz
$ cd zlib-1.2.8
$ ./configure
$ sudo make install
译注:也可用 yum install zlib-devel 替代
库 - nginx 的 SSL 模块依赖该库,用于支持 HTTPS 协议:
$ wget http://www.openssl.org/source/openssl-1.0.2f.tar.gz
$ tar -zxf openssl-1.0.2f.tar.gz
$ cd openssl-1.0.2f
$ ./configure darwin64-x86_64-cc --prefix=/usr
$ sudo make install
译注:也可用 yum install openssl-devel 替代
下载源码 tarball
源码 tarball 下载地址是:
mainline 版:
$ wget http://nginx.org/download/nginx-1.11.1.tar.gz
$ tar zxf nginx-1.11.1.tar.gz
$ cd nginx-1.11.1
stable 版:
$ wget http://nginx.org/download/nginx-1.10.1.tar.gz
$ tar zxf nginx-1.10.1.tar.gz
$ cd nginx-1.10.1
配置编译选项
源码包中提供 configure 脚本用于在编译前定义 nginx 各方面的配置。
执行 configure 脚本最后生成 Makefile,make 命令根据 Makefile 进行编译安装。
配置 nginx 文件安装路径
配置 nginx gcc 选项
指定 nginx 并发模型
nginx 的模块
默认编译的模块
默认不编译的模块
第三方模块
静态链接模块和动态链接模块
配置示例:
$ ./configure \
--sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-pcre=../pcre-8.38 \
--with-zlib=../zlib-1.2.8 \
--with-http_ssl_module \
--with-stream \
--with-mail=dynamic \
--add-module=/usr/build/nginx-rtmp-module \
--add-dynamic-module=/usr/build/3party_module
配置 nginx 文件安装路径
使用 configure 脚本可设置 nginx 的文件安装路径,包括 nginx 二进制文件和配置文件,以及设置依赖库如 PCRE 和 SSL 的源码所在路径(用于对其进行静态编译)。
--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-path=prefix/logs/error.log
--http-log-path=path
设置 nginx 访问日志的路径。安装nginx之后,可在 nginx.conf 文件中使用
指令修改该路径。默认 --http-log-path=prefix/logs/access.log
--user=name
设置启动 worker 进程时所使用的非特权用户名。安装nginx之后,可在 nginx.conf 文件中使用
指令修改用户名。默认 --user=nobody
--group=name
设置启动 worker 进程时所使用的非特权用户组名。安装nginx之后,可在 nginx.conf 文件中使用
指令修改用户组名。默认 --group=nobody
--with-pcre=path
设置 PCRE 库的源码路径。首先需要下载和解压
库。要求 PCRE 的版本范围为 4.4 — 8.38。设置之后,其余的就交给 ./configure 和 make 命令。nginx 使用 PCRE 库用于支持正则表达式。正则表达式在
模块中会用到。
--with-pcre-jit
编译 PCRE 库时,加入 “just-in-time compilation” 支持 (1.1.12, the
directive)
--with-zlib=path
设置 zlib 库的源码路径。首先需要下载和解压
要求 zlib 库的版本范围为 1.1.3 — 1.2.8,设置之后,其余的就交给 ./configure 和 make 命令。 压缩模块依赖 zlib 库。
配置 nginx gcc 选项
指定编译相关选项:
--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"。
指定 nginx 并发模型
--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,该模块被自动编译。
nginx 的模块
nginx 由很多模块组成。一些模块被默认编译进 nginx,因此不需要在 configure 脚本的选项中显式地指定。但是如果你希望不编译某个默认模块,可使用 --without-MODULE 选项将其排除在外。
没有默认编译的模块以及第三方模块,必须在执行 configure 脚本时进行显式地指定。对于这些模块,其中一部分是静态链接到 nginx 库,另一些是可动态链接到 nginx 库。
如果是静态链接到 nginx,当每次 nginx 启动时,这些模块被加载到 nginx 中。
如果是动态链接到 nginx,只有当在 nginx.conf 中指定了的该模块,模块才会被加载到 nginx 中。
默认编译的模块
如果你希望不编译某个默认模块,可使用 --without-MODULE 选项将其排除在外:
$ ./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-stream \
--with-pcre=../pcre-8.38 \
--with-zlib=../zlib-1.2.8 \
--without-http_empty_gif_module
在响应首部的 “Content-Type” 字段添加指定的字符集,能够对数据进行字符集转换。
使用 gzip 对响应报文进行压缩,可减少传输的数据大小,可减少一半或更多。
Processes SSI (Server Side Includes) commands in responses passing through it.
为客户端标识设置合适的 cookies
Limits access to certain client addresses.
通过 “IP地址” 限制某个客户端的访问
使用 HTTP 基本认证协议,对客户端进行认证,以限制对资源的访问。
Processes requests ending with the slash character (‘/’) and produces a directory listing.
Creates variables with values depending on the client IP address.
Creates variables whose values depend on values of other variables.
Creates variables suitable for A/B testing, also known as split testing.
对客户端的访问,如果在请求首部的 Referer 字段有无效的值,则阻止其对某个站点的访问。
使用正则表达式修改请求 URI,并返回重定向指令;根据条件判断选择配置。依赖于 PCRE 库。
将请求转发给其他服务器
将请求转发给 FastCGI 服务器。
将请求转发给 uwsgi 服务器。
将请求转发给 SCGI 服务器。
从一个 memcached 服务器获取响应。
对每个定义的 key,限制其连接数,特别是限制来自同一个 IP 地址的连接数。
对每个定义的 key,限制其请求的处理速率,特别是限制来自同一个 IP 地址的请求处理速率。
Emits single-pixel transparent GIF.
Creates variables whose values depend on the value of the “User-Agent” request header field.
激活基于 hash 的负载均衡策略
激活基于 IP hash 的负载均衡策略
激活基于 “最小连接数” 的负载均衡策略
激活 keepalive 连接保持
激活共享内存区
默认不编译的模块
一些模块是默认不编译的,你需要使用 ./configure 命令添加该选项。在这些默认不编译的模块中,有些模块可编译为动态模块,如下:
$ ./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-pcre=../pcre-8.38 \
--with-zlib=../zlib-1.2.8 \
--with-http_ssl_module \
--with-stream \
--with-mail
--with-threads
Enables NGINX to use thread pools. See ! blog post for details.
--with-file-aio
Enables asynchronous I/O.
--with-ipv6
Enables IPv6 support.
--with-http_ssl_module
Provides support for HTTPS. Requires an SSL library such as OpenSSL.See the
reference for the list of directives.
--with-http_v2_module
Provides support for .See the
reference for the list of directives and the “” blog post for details.
--with-http_realip_module
Changes the client address to the one sent in the specified header field. See the
reference for the list of directives.
--with-http_addition_module
Adds text before and after a response. See the
reference for the list of directives.
--with-http_xslt_module or --with-http_xslt_module=dynamic
Transforms XML responses using one or more XSLT stylesheets. The module requires the
libraries. See the
reference for the list of directives. The module can also be compiled as .
--with-http_image_filter_module or --with-http_image_filter_module=dynamic
Transforms images in JPEG, GIF, and PNG formats. The module requires the
library. See
reference for the list of directives. The module can also be compiled as dynamic.
--with-http_geoip_module or --with-http_geoip_module=dynamic
Allows creating variables whose values depend on the client IP address. The module uses
GeoIP databases. See the
reference for the list of directives. The module can also be compiled as dynamic.
--with-http_sub_module
Modifies a response by replacing one specified string by another. See the
reference for the list of directives.
--with-http_dav_module
Intended for file management automation via the WebDAV protocol. See the
reference for the list of directives.
--with-http_flv_module
Provides pseudo-streaming server-side support for Flash Video (FLV) files. See the ngx
reference for the list of directives.
--with-mp4_module
Provides pseudo-streaming server-side support for MP4 files. See the
reference for the list of directives.
--with-http_gunzip_module
Decompresses responses with Content-Encoding: gzip for clients that do not support zip encoding method. See the
for the list of directives.
--with-http_gzip_static_module
Allows sending precompressed files with the *.gz filename extension instead of regular files. See the
for the list of directives.
--with-http_auth_request_module
Implements client authorization based on the result of a subrequest. See the
for the list of directives.
--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. See the
for the list of directives.
--with-http_secure_link_module
Used to check authenticity of requested links, protect resources from unauthorized access, and limit link lifetime. See the
for the list of directives.
--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. See the
reference for the list of directives.
--with-http_degradation_module
Allows returning an error when a memory size exceeds the defined value.
--with-http_stub_status_module
Provides access to basic status information. See the
reference for the list of directives. Note that NGINX Plus customers do not require this module as they are already provided with extended status metrics and interactive dashboard.
--with-http_perl_module or --with-http_perl_module=dynamic
Used to implement location and variable handlers in Perl and insert Perl calls into SSI. Requires the
library. See the
reference for the list of directives. The module can also be compiled as dynamic.
--with-mail or --with-mail=dynamic
Enables mail proxy functionality. See the
reference for the list of directives. The module can also be compiled as 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 . See the
reference for the list of directives.
--with-stream or --with-stream=dynamic
Enables the TCP proxy functionality. See the
reference for the list of directives. The module can also be compiled as 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 . See the
reference for the list of directives.
--with-google_perftools_module
Allows using Google Performance tools library.
--with-cpp_test_module
--with-debug
Enables the .
第三方模块
你可以为 nginx 编译第三方模块,一些第三方模块可参见:。
使用第三方模块,需要自己承担稳定性的风险,因为第三方模块的稳定性是没有保证的。
静态链接模块和动态链接模块
静态链接模块
大多数被编译进 nginx 的模块是被静态链接的,它们在编译 nginx 时被构建到 nginx 中,并且被 nginx 的可执行文件静态地链接。被静态链接的模块无法被 disabled,只有重新编译 nginx 才能达到这个目的。
以静态方式编译第三方模块,如下所示,在执行 configure 脚本时,添加 --add-module= 选项,并输入模块的路径:
./configure ... --add-module=/usr/build/nginx-rtmp-module
动态链接模块
某些 nginx 模块也可以被编译为共享对象(*.so 文件),并在运行时被加载到 nginx 中。这种方式提供了更多的灵活性,因为可以自由选择加载或不加载某个动态模块。要加载某个动态模块,只要在 nginx.conf 中使用 指令指定该模块。
支持动态加载的模块,它们不是默认编译的:
以动态方式编译第三方模块,如下所示,在执行 configure 脚本时,添加 --add-dynamic-module= 选项,并输入模块的路径:
./configure ... --add-dynamic-module=/path/to/module
生成的 *.so 文件可在 prefix/modules/ 目录中找到,例如默认的路径为 /usr/local/nginx/modules。
安装完成后,如果要加载某个动态模块,只要在 nginx.conf 中使用 指令指定该模块。
相关扩展阅读:
使用 configure 脚本配置完成后,可进行编译安装:
$ sudo make install
安装顺利完成后,执行 nginx 命令,启动 nginx:
$ sudo nginx
安装预编译的 package
安装预编译的 package 相对更简单和快速。缺点是缺少灵活性。可安装预编译的 package 的系统有: Red Hat, CentOS, Debian, Ubuntu 以及 SLES。
预编译的 package 所包含的模块
关于预编译的 package 所包含的模块,请参见
安装 Red Hat/CentOS packages
nginx 为 Red Hat/CentOS 5, 5.x, 6, 6.x, 7 and 7.x 提供了预编译 package,package 有两个来源:
默认的 Red Hat or CentOS yum 仓库。这是最快的方式,但所提供的 package 版本比较老旧。比如说,CentOS 7.0 默认提供 nginx/1.6.2 released in September, 2014
nginx repo。为了从 nginx repo 安装 package,你需要设置相应的 yum 仓库。这里提供最新版本的 package
从默认的 Red Hat/CentOS 仓库安装 nginx
安装 EPEL 仓库:
$ sudo yum install epel-release
更新仓库,并安装 nginx:
$ sudo yum update
验证所安装的 nginx 版本:
$ sudo nginx -v nginx version: nginx/1.6.3
从 nginx repo 安装 nginx
设置 yum 仓库:
$ cd /etc/yum.repos.d $ sudo vi /etc/yum.repos.d/nginx.repo
添加如下内容:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/mainline/OS/OSRELEASE/$basearch/ gpgcheck=0 enabled=1
“OS” 是 rhel 或者 centos
“OSRELEASE” 为系统版本:5, 5.x, 6, 6.x, 7, 7.x
“/mainline” 是最新的 mainline 版。删除 “/mainline” 是安装最新的 stable 版
比如,为 CentOS 7.0 获取最新的 mainline package:
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
更新仓库,并安装 nginx:
$ sudo yum update
运行 nginx:
$ sudo nginx
验证 nginx 是否启动:
$ curl -I 127.0.0.1 HTTP/1.1 200 OK Server: nginx/1.11.1
版权信息:
本文编译自
Page 1:nginx 服务器安装及配置文件详解 CentOS 6.2 x86_64 安装 nginx 1.1 选择稳定版本#yum -y install gcc gcc-c++ make libtool lib zlib-devel openssl openssl-de...
Nginx简介 Nginx是什么 没有听过Nginx?那么一定听过它的“同行”Apache吧!Nginx同Apache一样都是一种WEB服务器。基于REST架构风格,以统一资源描述符(Uniform Resources Identifier)URI或者统一资源...
1.简介: ? Nginx:engine X ,2002年,开源,商业版? http协议:web服务器(类似于httpd)、http reverseproxy(类似于httpd)、imap/pop3 reverse proxy,tcp? NGINX is a free, o...
nginx 编辑Nginx (&engine x&) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。Nginx是由Igor Sysoev为俄罗斯访问量第二的Rambler.ru站点开发的,第一个公开版本0.1.0发布于...
nginx在工作中已经有好几个环境在使用了,每次都是重新去网上扒博客,各种编译配置,今天自己也整理一份安装文档和nginx.conf配置选项的说明,留作以后参考。像负载均衡配置(包括健康检查)、缓存(包括清空缓存)配置实例,请参考http://segmentfault.co...
冬末,在T市郊区的一处温室大棚内,我缓缓地睁开了双眼,一片明亮的光刺痛了我的眼,但我不愿意再把眼睛闭上,我知道那是阳光,是赋予我生命的强大力量,我很庆幸在那个天寒地冻的冬天里,我依旧能够在这样温暖的环境下出生,我喜欢这温室,它的空气还有这明亮的阳光。 我是一个番茄,也有人叫...
我最早听到别人讲退休的话,是在刚毕业找工作的时候。 那是一个朋友的哥哥,当时在松下电器上班,已经做到销售部门的经理。见面聊天的时候,那个哥哥说:希望再工作几年就可以退休了。他的年龄当时35不到,我当时的感觉是“哇,厉害”,这么年轻就可以退休了。13年过去了,我不知道他退了吗...
看着你问我的问题,我一个也回答不出来,我爱的是什么,我舍不得的是什么,我这样自我折磨是要给谁看,我这样子值得不值得,我需要的是什么,这些也是我想寻求的,我不知道为什么,想不通为什么。你说你真想狠狠地打我一顿,把现在这个沉默悲伤的我打跑,换回那个简单爱说爱笑逗比的我。几...
北京时间8月22日上午,2016年里约奥运会闭幕式在马拉卡纳球场举行。随着闭幕式的落幕,里约奥运会也就结束了,虽然里约奥运结束了,但是我们的脑海中依然回放着他们的身影。 【女排12年再登顶 郎平的两次执教】 ”女排精神不是赢得冠军,而是有时候知道不会赢,也竭尽全力,是你一路...在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
官方仓库地址:官方下载页地址:问题:官方下载页显示主线版本是1.9.12,官方仓库里面没有,有个2.0系列,什么意思?
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
源码看这里:
希望有所帮助~ :)
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
因为主线版相当于开发版,不适合生产环境使用。
同步到新浪微博
分享到微博?
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:
在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。

我要回帖

更多关于 nginx docker私有仓库 的文章

 

随机推荐