CentOS 8 yum/dnf 安裝 NGINX 穩定或最新版本 - MIS 腳印
MIS 腳印 logo

MIS 腳印

記錄 IT 學習的軌跡

CentOS 8 yum/dnf 安裝 NGINX 穩定或最新版本

CentOS 8 預設 AppStream 軟體倉庫 (repo,repository) 提供的 NGINX 版本為 1.14.1,本文章透過 NGINX 官方軟體倉庫,即可使用 yum/dnf 指令來安裝 NGINX 穩定或最新版本。

CentOS

移除舊有已安裝 NGINX

查看現有安裝 NGINX 版本:

nginx -v
nginx version: nginx/1.14.1

移除已安裝的 NGINX:

yum remove nginx -y

移除 NGINX 設定檔:

rm -rf /etc/nginx/

安裝 NGINX 穩定或最新版本

安裝能夠選擇指定 yum 的套件:

yum install yum-utils -y

新增 NGINX 官方軟體倉庫 (repository):

vim /etc/yum.repos.d/nginx.repo
# 穩定版
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
module_hotfixes=true

# 最新版
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=0
enabled=0
module_hotfixes=true

切換使用 nginx-stable 穩定版:

yum-config-manager --enable nginx-stable

查看欲安裝的 NGINX 版本資訊:

 yum info nginx
上次中介資料過期檢查:0:07:49 以前,時間點為西元2020年04月05日 (週日) 11時17分11秒。
可用的軟體包
Name         : nginx
Epoch        : 1
Version      : 1.16.1
發行版       : 1.el8.ngx
Architecture : x86_64
Size         : 797 k
來源         : nginx-1.16.1-1.el8.ngx.src.rpm
Repository   : nginx-stable
Summary      : High performance web server
URL          : http://nginx.org/
授權         : 2-clause BSD-like license
Description  : nginx [engine x] is an HTTP and reverse proxy server, as well as
             : a mail proxy server.

安裝 NGINX:

yum install nginx -y

查看安裝的 NGINX 版本:

nginx -v
nginx version: nginx/1.16.1

參考

在〈CentOS 8 yum/dnf 安裝 NGINX 穩定或最新版本〉中有 5 則留言

  1. 謝謝你寫這篇教學文章 很詳細 在我用CentOS安裝OwnCloud時,受宜良多,十分感謝。

  2. 太感謝了~CentOS8 內建的功能在太實用了,改善之前升級不便的地方

發表迴響