将最新版的Nginx稳定版安装到Ubuntu 16.04中(使用官方仓库)

首先

使用公式存储库在Ubuntu 16.04上安装最新稳定版的Nginx。
原文链接:Nginx各种安装方式和EOL整理
参考:nginx:Linux软件包

支持

如果使用这种方法引入,我认为nginx将得到支持直到开发停止。
如果不指定特定版本,我认为稳定的最新版本将始终被提供。

日志

仓库注册

# apt update; apt install -y curl gnupg2 ca-certificates lsb-release
# echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | tee /etc/apt/sources.list.d/nginx.list
# curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add -

# apt-key fingerprint ABF5BD827BD9BF62
pub   2048R/7BD9BF62 2011-08-19 [expires: 2024-06-14]
      Key fingerprint = 573B FD6B 3D8F BC64 1079  A6AB ABF5 BD82 7BD9 BF62
uid                  nginx signing key <signing-key@nginx.com>

安装

# cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.6 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.6 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

# apt update; apt install -y nginx
... 略

确认的各种方式

# which nginx
/usr/sbin/nginx

# nginx -v
nginx version: nginx/1.16.1

# apt show nginx
Package: nginx
Version: 1.16.1-1~xenial
Priority: optional
Section: httpd
Maintainer: Sergey Budnevitch <sb@nginx.com>
Installed-Size: 3007 kB
Provides: httpd
Depends: init-system-helpers (>= 1.18~), libc6 (>= 2.17), libpcre3, libssl1.0.0 (>= 1.0.2~beta3), zlib1g (>= 1:1.1.4), lsb-base (>= 3.0-6), adduser
Conflicts: nginx-common, nginx-core
Replaces: nginx-common, nginx-core
Homepage: http://nginx.org
Download-Size: 839 kB
APT-Manual-Installed: yes
APT-Sources: http://nginx.org/packages/ubuntu xenial/nginx amd64 Packages
Description: high performance web server
 nginx [engine x] is an HTTP and reverse proxy server, as well as
 a mail proxy server.

N: There are 13 additional records. Please use the '-a' switch to see them.