Excellent software and practical tutorials
How to install the latest version of Nginx on CentOS8
nginx versionWhat to do if the default software repository of CentOS8 has a built-in nginx version of 1.14.1. Recently, a scan has been performed to indicate that it needs to be upgraded to version 1.17.7 or higher. Here is how to install it:The latest version of nginx, and install the specified Nginx version.
nginx official source installation
In the /etc/yum.repos.d/ directory, create a new nginx.repo file:
vi /etc/yum.repos.d/nginx.repo
Paste the following content into the nginx.repo 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
[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
The nignx version in the system and EPEL source is older. Use the official source above to install the latest version.
After saving and exiting, execute the dnf list command to list all versions of nginx:
dnf list nginx --showduplicates
The nginx version currently installed in the system is nginx1.14.1. The following is to upgrade the nginx version.
View the latest version of nginx:
dnf info nginx
Install the latest version of nginx:
dnf install nginx
Update the latest version of nginx from a lower version:
dnf update
Note: If you update nginx from an earlier version, please back up the files first.
Install the specified version of nginx:
dnf install nginx-1.18.0
If you don't wantInstall nginxThe latest version is 1.20.2. You can also install a specific version of nginx by adding the version number after nginx-.
Check the nginx version:
nginx -v
ChecknginxInstallation package information:
rpm -qi nginx
Uninstall nginx:
dnf remove nginx
If you want to uninstall nginx, you can execute dnf remove nginx Order.
Install Nginx from other sources
In the /etc/yum.repos.d/ directory, create a new nginx.repo file:
vi /etc/yum.repos.d/nginx.repo
Paste the following content into the nginx.repo file:
[nginx-mainline]
name=nginx mainline repo
baseurl=http://mirrors.ustc.edu.cn/nginx/mainline/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
module_hotfixes=true
Save and exit. The installation method is the same as above.