How to Install Latest Version of ngnix (1.15.4) on Centos 7

Dated : 29-09-2018

Nginx is a flat,light weight,powerful HTTP web server. In this piece of writing, we will illustrate about ngnix web server latest version installation on centos 7 and How to allow traffic for HTTP services,because by default the HTTP traffic are blocked.

Introduction :

Latest version of Nginx is not a part of CentOS default repositories.We can’t run and install nginx just by using ‘yum’ command.For the installation we need external repositories.

There are two Nginx repositories are available from Nginx as Stable and Mainline repositories as mentioned in http://nginx.org/en/download.html

If we are going to install Latest version always prefer Mainline repositories,because this repositories will contain newly added features to nginx.In stable repositories, the versions which are tested and proven will be there.All the new features are firstly introduced in mainline repository and after testing and validation about their proper functioning they will be move down to the stable repository.

Assumption : 

We are working on Linux Distibution – Centos 7 x86_64 and the web Server path will be /etc/ngnix

Installation Process

Step 1 : Create new repository for nginx

To need to install latest version and add to the mainline repository,run the following command

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

Now,copy and paste the below lines depending upon the requirement (Mainline or Stable repository)  into nginx.repo file & save it,

for Mainline repository,

[nginx]

name=nginx

repo

baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/

gpgcheck=0

enabled=1

for Stable repository,

[nginx]

name=nginx

repo

baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/

gpgcheck=0

enabled=1

 

Step 2 : Installation of nginx

Run the below command to install nginx

sudo yum install nginx

Kudos ! it’s over.

Now you can browse using host name or IP to access the nginx page.The page will be look as like shown below,

Step 3: Permission for HTTP Traffic to Nginx web server

By default HTTP traffic is not allowed to Centos 7.In order to allow the traffic,we need to open the firewall by adding following services as shown below,

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

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

sudo firewall-cmd --reload

 

Hope you installed it successfully.Enjoy!

Please feel free to provide constructive feedback. Comments are greatly appreciated !

 

Leave a Reply