Enable automatic updates of nginx using yum repository for RHEL/CentOS distributions

Updated on September 2, 2017

nginx spelled as “Engine X” is an HTTP and reverse proxy server, as well as a mail proxy server, written by Igor Sysoev. Initially it was used for running heavily loaded Russian sites including, Yandex, Mail.Ru, VKontakte and Rambler. According to Netcraft, an Internet service company which provides web server and web hosting market-share analysis, nginx served nearly 16% of the busiest sites in Jan 2014. Few sites who are running their domains on nginx are : Netflix, WordPress.com, FastMail.fm etc.,

nginx has released binary packages, apart from source installation package for RHEL/CentOS. To enable automatic updates of nginx packages, set up yum repository for the RHEL/CentOS distributions.

Step 1: Setup yum repository of nginx for RHEL/CentOS using rpm

To set up the yum repository of nginx for RHEL/CentOS, choose the corresponding nginx-release package from the list:

RHEL5
RHEL6
CentOS5
CentOS6

This package contains yum configuration file and a public PGP key necessary to authenticate signed RPMs. Download and install it using below command:

#rpm -ihv nginx-release-centos-5-0.el5.ngx.noarch.rpm

Below gif image shows, downloading rpm package, find files in rpm package, extract files from rpm package and install the rpm package.

yum repo configuration for nginx
yum repo configuration for nginx

Step 2: Manual configuration of yum repository for RHEL/CentOS

Alternatively, you can configure manually without installing the nginx-release package using rpm. Create a file nginx.repo under /etc/yum.repos.d/ with the help of your favorite editor and add the following lines of code to it based on your OS Architecture.

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

Replace “os” with “rhel” or “centos”, depending on the distribution used and “OSRELEASE” with “5” or “6” for 5.x and 6.x versions respectively.

Below gif shows the manual configuration for centos 5.

manual yum repo configuration nginx
manual yum repo configuration nginx

Step 3: Install nginx web-server using yum repository

Type the following yum command to install nginx web-server:

# yum install nginx

Below gif image shows the nginx installation using yum.

nginx installation using yum
nginx installation using yum

Now you have installed nginx, follow to learn basic configuration and run nginx.

Was this article helpful?

Related Articles

Leave a Comment