设置yum源
[root@centos8 ~]#cat /etc/yum.repos.d/nginx.repo
[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
列出所有列表
root@zz yum.repos.d]# yum list nginx --showduplicates
nginx stable repo 12 kB/s | 48 kB 00:04
Available Packages
nginx.x86_64 1.16.0-1.el8.ngx nginx-stable
nginx.x86_64 1:1.14.1-9.module+el8.4.0+542+81547229 appstream
nginx.x86_64 1:1.16.1-1.el8.ngx nginx-stable
nginx.x86_64 1:1.18.0-1.el8.ngx nginx-stable
nginx.x86_64 1:1.18.0-2.el8.ngx nginx-stable
nginx.x86_64 1:1.20.0-1.el8.ngx nginx-stable
nginx.x86_64 1:1.20.1-1.el8.ngx nginx-stable
nginx.x86_64 1:1.20.2-1.el8.ngx nginx-stable
nginx.x86_64 1:1.22.0-1.el8.ngx nginx-stable
nginx.x86_64 1:1.22.1-1.el8.ngx
安装1.20.2
yum -y install nginx-1.20.2
查看版本
nginx -v
nginx version: nginx/1.20.2
开机启动
systemctl enable nginx --now