Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to install Nginx on CentOS/RHEL


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

CentOS/RHEL 8

# 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,

http://IP_ADDRESS_OF_THE_SERVER


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

[nginx]

name=nginx repo

baseurl=https://nginx.org/packages/$OS/$releaserver/$basearch/

gpgcheck=0

enabled=1

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,

[nginx]

name=nginx repo

baseurl=https://nginx.org/packages/centos/7/basearch/

gpgcheck=0

enabled=1

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.

The post How to install Nginx on CentOS/RHEL appeared first on The Linux GURUS.



This post first appeared on The Linux GURUS, please read the originial post: here

Share the post

How to install Nginx on CentOS/RHEL

×

Subscribe to The Linux Gurus

Get updates delivered right to your inbox!

Thank you for your subscription

×