Javatpoint Logo
Javatpoint Logo

Installing NGINX on Redhat/CentOS

Nginx can be installed in two ways:

  • We can install Nginx from default RHEL or CentOS repository. This is the easiest and quickest way, but generally the provided packages are outdated.
  • We can also install Nginx from the official repo at nginx.org. For this we have to set up the yum repository the first time only, but after that the provided package is always up to date.

Installing Nginx from OS repository

Step 1: Install the EPEL repository for Nginx package

Here, EPEL stands for Extra Packages for Enterprise Linux. Since, yum as a package manager does not include the latest version of Nginx in its default repository; installing EPEL will make sure that Nginx on RHEL or CentOS stays up to date.

Use the following command to install the epel repository.

Step 2: Update Repository

Use the following command to update the repository.

Step 3: Install Nginx

To install Nginx, use the following command:

Step 4: Verify the installation

To verify that the nginx is installed successfully or not or to know the version of nginx, use the following command.

Installing Nginx from the Official Nginx Repository

Step1: Create the yum repository for RHEL or CentOS by creating the file nginx.org in etc./yum.repos.d, to setup the yum repository here I am using vi editor:

Step 2: Add the following lines of code to nginx.repo

Here,

  • The /mainline is points to the latest mainline version of NGINX open source, delete it to get the latest stable version.
  • this the name of OS i.e. either rhel or centos
  • this element is the release number such as 6, 6._x, 7, 7._x_ and so on.

For example, to get the latest mainline package for CentOS 7, use the following command:

Step 3: Save the file by pressing ESC, and wq at the : prompt.

Step 4: Update Repository

Use the following command to update the repository.

Step 5: Install Nginx

To install the Nginx, use the following command:

Step 6: Verify the installation

To verify that the nginx is installed successfully or not or to know the version of nginx use the following command:






Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA