备忘录:使用dnf在CentOS8上从官方软件仓库安装nginx

過程

将其添加到存储库中。

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

从以上存储库中排除AppStream。

$ dnf --disablerepo=AppStream info nginx
nginx repo                                                                               22 kB/s |  47 kB     00:02
Available Packages
Name         : nginx
Epoch        : 1
Version      : 1.19.3
Release      : 1.el8.ngx
Architecture : x86_64
Size         : 814 k
Source       : nginx-1.19.3-1.el8.ngx.src.rpm
Repository   : nginx
Summary      : High performance web server
URL          : http://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.

安装

$ sudo dnf --disablerepo=AppStream install nginx
nginx repo                                                                               27 kB/s |  47 kB     00:01
Last metadata expiration check: 0:00:01 ago on Tue 06 Oct 2020 01:45:05 AM UTC.
Dependencies resolved.
========================================================================================================================
 Package                 Architecture             Version                                 Repository               Size
========================================================================================================================
Installing:
 nginx                   x86_64                   1:1.19.3-1.el8.ngx                      nginx                   814 k

Transaction Summary
========================================================================================================================
Install  1 Package

Total download size: 814 k
Installed size: 2.8 M
Is this ok [y/N]: y ← y応答
Downloading Packages:
nginx-1.19.3-1.el8.ngx.x86_64.rpm                                                       302 kB/s | 814 kB     00:02
------------------------------------------------------------------------------------------------------------------------Total                                                                                   302 kB/s | 814 kB     00:02
warning: /var/cache/dnf/nginx-f354473966140c6b/packages/nginx-1.19.3-1.el8.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
nginx repo                                                                              1.4 kB/s | 1.5 kB     00:01
Importing GPG key 0x7BD9BF62:
 Userid     : "nginx signing key <signing-key@nginx.com>"
 Fingerprint: 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62
 From       : https://nginx.org/keys/nginx_signing.key
Is this ok [y/N]: y ← y応答
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                1/1
  Running scriptlet: nginx-1:1.19.3-1.el8.ngx.x86_64                                                                1/1
  Installing       : nginx-1:1.19.3-1.el8.ngx.x86_64                                                                1/1
  Running scriptlet: nginx-1:1.19.3-1.el8.ngx.x86_64                                                                1/1
----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:
* http://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:
* http://nginx.com/products/

----------------------------------------------------------------------

  Verifying        : nginx-1:1.19.3-1.el8.ngx.x86_64                                                                1/1

Installed:
  nginx-1:1.19.3-1.el8.ngx.x86_64

Complete!

开机

$ sudo systemctl start nginx

自动启动设置

$ sudo systemctl enable nginx

停下来

$ sudo systemctl stop nginx