How to choose nginx version during rpm install

According to nginx.org instruction on how to install nginx by .rpm, it says that I should do the following.

open nginx.repo

$ vi /etc/yum.repos.d/nginx.repo

paste the following content in it (for CentOs7)

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

then simply do yum install nginx

This works, but it installs the mainline version and not the stable one. As of now I have 1.8.0

[root@localhost ~]# nginx -v
nginx version: nginx/1.8.0

So, my question is, how do I install the stable version which is currently, at v1.6.3 according to nginx.org

2015-04-07 nginx-1.6.3 stable and nginx-1.7.12 mainline versions have been released.


Solution 1:

First, you should take a look at what packages are available

yum --showduplicates list nginx

Looking at that repo, it appears that nginx 1.6.3-1 is the version you want.

You can install the specific version by appending it to the package name with a dash:

yum install nginx-1.6.3-1

That said, nginx 1.8 has been released as stable.

Solution 2:

In case someone is searching for the installation of nginx 1.8, the following does not show nginx-1.8

yum --showduplicates list nginx

You can use a single command as below to download and install a rpm

sudo rpm -Uvh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.8.0-1.el7.ngx.x86_64.rpm