Nginx is one a very famous, open-source web server application that we can also use as a reverse proxy, cache server as well as a load balancer among other things. It is a powerful, lightweight application & also uses very few resources.

In this tutorial, we will learn how to install Ngnix on CentOS & RHEL servers. There are two ways with which we can install the Nginx on CentOS & RHEL, either using EPEL repositories or using the Nginx official repositories.

Recommended Read: How to install NGINX on Ubuntu

Also Read: Scheduling CRON Jobs with Crontab for Beginners

Install Nginx on CentOS/RHEL using the EPEL repository

Nginx packages are not maintained on the default CentOS/RHEL repositories & are available on the EPEL repositories. So we need to install EPEL repositories on it first.

We have already discussed in detail how we can install the EPEL repository on CentOS in our tutorial HERE. You can also run the following

CentOS/RHEL 6/7

# yum install epel-release


# dnf install epel-release

Once the EPEL repository has been installed, we can then install nginx with the following command,

# yum install nginx

Once the nginx is installed, we can then start the nginx service with the following command,

# systemctl start nginx

To enable the server at boot time, run the following command,

# systemctl enable nginx

When the nginx service has started, we can access the default nginx webpage with the system IP address from a browser,


Install Nginx on CentOS using the Official Nginx repository

For enabling the official Nginx repositories, we need to create the repository files for nginx repos. Create a file ‘/etc/yum.repos.d/ngnix.repo’ & enter the following details,

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


name=nginx repo




Here, we need to update the following values as per the OS type & version number, i.e.,

OS – rhel or centos

releaseserver – 6, 7 or 8

For example, the entry for Centos 7 would be,


name=nginx repo




Similarly, replace Centos with rhel for rhel 7 Nginx repository. Now, all we need is to install Nginx with the following command,

# yum install nginx

Now, start the nginx service & access the default webpage.

This completes our tutorial on how to install nginx on CentOS/RHEL. You can also check our tutorial on how to host multiple websites on Nginx HERE & if you have any questions/queries, please do let us know using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.