How to install Nginx on RHEL 8 / CentOS 8 via package manager - dnf

  • Last updated: Nov 3, 2023
  • Views: 1371
  • Author: Admin
How to install Nginx on RHEL 8 / CentOS 8 via package manager - dnf

Hello colleagues.

In today's article, we will talk about how to install the latest and stable version of the Nginx web server on Centos or Redhat version 8 from the dnf package manager.

Nginx is one of the most popular HTTP web servers in the world. Nginx can serve very large, high-traffic sites while using fewer resources than the Apache web server. Also nginx has the ability to use it as a reverse proxy server.

 

Let's start the installation.

 

The first thing we will start with is to install all the updates on our Linux server, if any. To install the update, use the command:

$. sudo dnf update -y

install nginx on centos 8

I recently updated my server, so I don't have any updates at the moment.


 

First, let's check which versions of nginx are in the standard Centos 8 repository. To check, use the command:

$. sudo dnf module list nginx

install nginx on centos 8

As you can see from the screenshot, not all versions of the Nginx web server are available in the standard Centos 8 repository, and we want to install the newest and most stable version.


 

In order for us to install the newest and most stable version of Nginx, we need to add the Nginx repository to our Linux server.

Add Nginx repository.

We go to the directory where we have all the repositories of our Linux server.

$. cd /etc/yum.repos.d

Create the nginx.repo file

$. sudo vim nginx.repo

Add content to the file:

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

install nginx on centos 8

We save and close the file.


 

Now that we have added the Nginx repository to our server, we can now start installing Nginx. To install, run a simple command:

$. sudo yum install nginx

install nginx on centos 8

Confirm the installation of Nginx with the y key.


 

After our Nginx is installed, now we have to check its version, for this use the command:

$. nginx -v

install nginx on centos 8

Success.


 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES

Linux - How to Install PHP Composer on CentOS 8

Linux - How to Install PHP Composer on CentOS 8

How to Install PHP 8 on Ubuntu 20.04 LTS

How to Install PHP 8 on Ubuntu 20.04 LTS

How to Install Galera Cluster Manager on Centos

How to Install Galera Cluster Manager on Centos