How to install Nginx on RHEL 8 / CentOS 8 via package manager - dnf
- Last updated: Nov 3, 2023
- Views: 1003
- Author: Admin
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
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
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:
name=nginx stable repo
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
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
Thank you all, I hope my article was of some help to you.