Ubuntu20.04使用中科大镜像源安装更新nginx

添加镜像源

$ sudo vim /etc/apt/sources.list.d/nginx.list

使用mainline可以获取到最新版本的nginx,配置内容如下:

deb http://mirrors.ustc.edu.cn/nginx/mainline/ubuntu/ focal nginx

添加GPG密钥与安装

直接运行sudo apt update会报错:

W: GPG error: http://mirrors.ustc.edu.cn/nginx/ubuntu focal InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ABF5BD827BD9BF62
E: The repository 'http://mirrors.ustc.edu.cn/nginx/ubuntu focal InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

需要将上面NO_PUBKEY后面的公钥进行导入(注意根据实际提示替换命令最后的公钥内容)

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABF5BD827BD9BF62
sudo apt update
sudo apt install -y nginx

安装完成后检查当前nginx版本,与官网上mainline的最新版本一致

$ nginx -v
nginx version: nginx/1.19.1

你可能感兴趣的:(运维)