Nginx 1.7.11 was released few days ago and this brief tutorial is going to show you how to install or upgrade to the latest version of Nginx on CentOS 7. If you’re not already using Nginx web server to power your blogs or websites, you should give it a try as it’s a very fast web server. It has helped us greatly on this blog.

Few years ago, we switched from Apache to Nginx to help speed up our web pages in order to rank better on Google’s search engine result pages. We did speed up our web pages, but we haven’t achieved better positions on Google search engine pages just yet.

While we have improved our site performance, we haven’t seen great results in our search ranking. It maybe because of other factors and not speed, but I don’t have clue why our web traffic has continued to decline.

Nginx version 1.7.11 released few days ago brought many new features and bug fixes. New features such as experimental thread pools support, client SSL certificates support in mail proxy, startup speedup when using the “hash … consistent” directive in the upstream block and many others.

The new version of Nginx also fixed issues related to SSL by enabling SLv3  support with LibreSSL, ignoring stale global SSL error … called a function you should not call alerts appeared in logs when using LibreSSL and  “proxy_cache_revalidate” directive error.

To get the last version of Nginx, you must install Nginx’s mainline repository onto your system. Nginx has two main repositories you can install software from.. The two repositories are stable and mainline. The stable repository contains software that are tested and proven to function with most systems. Less bugs are found in the stable repository as compared to the mainline.

The mainline repository contains the latest version of software that are not in the stable repository. So to get the latest version of Nginx, download and install the mainline repository. To do that, run the commands below to create a new Nginx’s repository file on your system

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

Then copy and paste these lines into the file and save it.

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

After that, run the command below to update your system

sudo yum update

Finally, to install Nginx, run the commands below.

sudo yum install nginx

After installing Nginx, run the commands below to view the current version installed on your system.

nginx -v

And you’ll see something like the line below.

nginx version: nginx/1.7.11

If you’re installing Nginx on a new CentOS machine, you must also enable HTTP/HTTPS ports to allow web traffic. Without opening these ports, your users may never see your web content.

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

That’s it!

Enjoy!