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

2020.9.19更新

换了台Ubuntu 20.04的服务器使用上面的方法进行更新的时候提示:

N: Skipping acquire of configured file 'nginx/binary-i386/Packages' as repository 'http://mirrors.ustc.edu.cn/nginx/mainline/ubuntu focal InRelease' doesn't support architecture 'i386'

系统是64位的,apt更新提示不支持i386架构关我毛事儿…翻了下中科大的镜像站目录发现确实不支持32位的架构:

在这里插入图片描述
修改一下/etc/apt/sources.list.d/nginx.list配置,指定系统架构[arch=amd64]:

deb [arch=amd64] http://mirrors.ustc.edu.cn/nginx/mainline/ubuntu/ focal nginx

再重新apt update:

1 package can be upgraded. Run 'apt list --upgradable' to see it.
N: Skipping acquire of configured file 'nginx/binary-i386/Packages' as repository 'http://mirrors.ustc.edu.cn/nginx/mainline/ubuntu focal InRelease' doesn't support architecture 'i386'

重新apt upgrade:

The following packages have been kept back:
  nginx
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

擦~还是不能更新,翻了下stackoverflow,手工重新安装nginx:

$ sudo apt install nginx -y
$ sudo systemctl restart nginx	# 重新安装后需要重启一下服务(重装后服务是停着的)
$ nginx -v
nginx version: nginx/1.19.2
# OJBK了
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DexterLien

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值