Linux

How to install latest official Nginx on Centos 8 / RHEL 8

How to install latest official Nginx on Centos 8 / RHEL 8, instead using Nginx from Centos 8 or RHEL 8 repository.

Currently Centos / RHEL 8 repo using too old version of Nginx 1.14.1.

If you already install Nginx 1.14.1 remove it first

# dnf remove nginx

First install dnf-utils

# dnf install dnf-utils

Create file in /etc/yum.repos.d/nginx.repo and paste code below

[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

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

By default, the repository for stable nginx packages is used. If you would like to use mainline nginx packages, run the following command:

Related Post
sudo yum-config-manager --enable nginx-mainline

If you running on production server, choose Nginx stable version.

To install nginx, run the following command:

# dnf install nginx

When prompted to accept the GPG key, accept it.

Enable Nginx start up and start Nginx.

# systemctl enable nginx
# systemctl start nginx

View Comments

  • Will DNF install a newer version of Nginx than the crappy Yum did? (1.14.1)? Which version of PHP and PHP-FPM will we install?

  • I am genuinely grateful to the holder of this site who has shared this fantastic post at at this place.

  • Aw, this was an incredibly nice post. Finding the time
    and actual effort to generate a really good article… but what can I
    say… I hesitate a lot and never seem to get anything done.

Recent Posts

How to fix yum update error thread.error: can’t start new thread

If you found error thread.error: can't start new thread on yum update command on CentOS…

5 months ago

How to securing Cockpit login with Google Two Factor Authenticator 2FA

Cockpit is a web-based graphical interface for servers, intended for everyone, especially those who are:…

8 months ago

How to install Cockpit on CentOS 7 / CentOS 9 Stream and configure Nginx reserve proxy

From cockpit-project.org, Cockpit is a web-based graphical interface for servers, intended for everyone, especially those…

11 months ago

How to install and configure Nginx with HTTP3 on CentOS 9 Stream / RHEL 9

We have been using Nginx with HTTP3 for more than 1 year on our production…

11 months ago

How to sync date time using Crony on CentOS 9 Stream / RHEL 9

On CentOS 7, to sync date time we often use NTPD. But on CentOS 9,…

11 months ago

How to install and enable REMI repository on CentOS 9 Stream

Remi repository is one of third-party repository that have latest update of PHP on Enterprise…

11 months ago