天天看點

centos8安裝最新版nginx使用yum

1,安裝yum-utils,輸入指令:

yum install yum-utils

2,添加nginx源。CentOS8系統自帶的nginx源版本是1.14,這裡我們自己建立高版本的nginx源,建立檔案/etc/yum/repos.d/nginx.repo,指令:

vim /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/

enabled=0

3、檢視nginx源,指令:yum info nginx,nginx源的版本是1.20.1

[root@hecs-76146 ~]# yum info nginx

Last metadata expiration check: 0:05:48 ago on Wed 11 Aug 2021 10:43:41 AM CST.

Installed Packages

Name         : nginx

Epoch        : 1

Version      : 1.20.1

Release      : 1.el8.ngx

Architecture : x86_64

Size         : 2.8 M

Source       : nginx-1.20.1-1.el8.ngx.src.rpm

Repository   : @System

From repo    : nginx-stable

Summary      : High performance web server

URL          : https://nginx.org/

License      : 2-clause BSD-like license

Description  : nginx [engine x] is an HTTP and reverse proxy server, as well as

             : a mail proxy server.

4,安裝nginx,指令:

yum install nginx