软件包‘nginx’没有安装候选项

软件包‘nginx’没有安装候选项

服务器出现问题。我想将 NGINX 升级到较新的版本,但无论我如何尝试,我都会得到

?E:软件包‘nginx’没有安装候选项

我第一次尝试sudo apt-get update && sudo apt-get upgrade

sudo apt-get update
Hit:1 https://deb.nodesource.com/node_14.x focal InRelease
Hit:2 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:4 http://archive.canonical.com/ubuntu focal InRelease
Hit:5 http://archive.ubuntu.com/ubuntu focal-security InRelease
Hit:6 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Get:7 https://packages.amplify.nginx.com/ubuntu focal InRelease [3818 B]
Hit:8 http://archive.ubuntu.com/ubuntu focal-proposed InRelease
Hit:9 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Get:10 https://packages.amplify.nginx.com/ubuntu focal/amplify-agent amd64 Packages [557 B]
Fetched 4375 B in 1s (3977 B/s)
Reading package lists... Done

sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

dpkg --get-selections | grep hold不返回任何东西,所以这些包裹不会被扣留

我检查了一下/var/log/unattended-upgrades/unattended-upgrades.log,发现

2020-07-04 06:31:38,584 INFO Starting unattended upgrades script
2020-07-04 06:31:38,585 INFO Allowed origins are: o=Ubuntu,a=focal, o=Ubuntu,a=focal-security, o=UbuntuESMApps,a=focal-apps-security, o=UbuntuESM,a=focal-infra-security, o=UbuntuESM,a=focal-security
2020-07-04 06:31:38,585 INFO Initial blacklist:
2020-07-04 06:31:38,585 INFO Initial whitelist (not strict):
2020-07-04 06:31:39,944 INFO No packages found that can be upgraded unattended and no pending auto-removals
2020-07-04 06:31:40,074 INFO Package nginx is kept back because a related package is kept back or due to local apt_preferences(5).
2020-07-04 06:39:52,369 INFO Starting unattended upgrades script
2020-07-04 06:39:52,370 INFO Allowed origins are: o=Ubuntu,a=focal, o=Ubuntu,a=focal-security, o=UbuntuESMApps,a=focal-apps-security, o=UbuntuESM,a=focal-infra-security, o=UbuntuESM,a=focal-security
2020-07-04 06:39:52,370 INFO Initial blacklist:
2020-07-04 06:39:52,375 INFO Initial whitelist (not strict):

我觉得,这是一个简单的解决办法

sudo apt-get install nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package nginx is a virtual package provided by:
  nginx-light 1.18.0-0ubuntu1 [Not candidate version]
  nginx-full 1.18.0-0ubuntu1 [Not candidate version]
  nginx-extras 1.18.0-0ubuntu1 [Not candidate version]
  nginx-core 1.18.0-0ubuntu1 [Not candidate version]
  nginx-light 1.17.10-0ubuntu1 [Not candidate version]
  nginx-full 1.17.10-0ubuntu1 [Not candidate version]
  nginx-extras 1.17.10-0ubuntu1 [Not candidate version]
  nginx-core 1.17.10-0ubuntu1 [Not candidate version]

E: Package 'nginx' has no installation candidate

所以我跑sudo apt-cache policy nginx了回来

nginx:
  Installed: 1.17.2-1-ppa7~bionic
  Candidate: (none)
  Version table:
     1.18.0-0ubuntu1 -1
        500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
     1.17.10-0ubuntu1 -1
        500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
 *** 1.17.2-1-ppa7~bionic -1
        100 /var/lib/dpkg/status

我检查了一下/etc/apt/sources.list,里面一切看上去都正常......

###### Ubuntu Main Repos
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse

###### Ubuntu Update Repos
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

###### Ubuntu Partner Repo
deb http://archive.canonical.com/ubuntu focal partner
deb-src http://archive.canonical.com/ubuntu focal partner

###### Ubuntu Extras Repo
deb http://apt.postgresql.org/pub/repos/apt focal-pgdg main

我尝试使用以下方法设置 /etc/apt/sources.list.d/nginx.list

deb http://nginx.org/packages/mainline/ubuntu/ focal nginx 
deb-src http://nginx.org/packages/mainline/ubuntu/ focal nginx

但那也没用。所以我尝试卸载并清除 nginx-*(因此它包括 common 等),但现在我根本无法安装 nginx,因为它仍然说没有安装候选项。

 sudo apt-get install nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package nginx is a virtual package provided by:
  nginx-light 1.18.0-0ubuntu1 [Not candidate version]
  nginx-full 1.18.0-0ubuntu1 [Not candidate version]
  nginx-extras 1.18.0-0ubuntu1 [Not candidate version]
  nginx-core 1.18.0-0ubuntu1 [Not candidate version]
  nginx-light 1.17.10-0ubuntu1 [Not candidate version]
  nginx-full 1.17.10-0ubuntu1 [Not candidate version]
  nginx-extras 1.17.10-0ubuntu1 [Not candidate version]
  nginx-core 1.17.10-0ubuntu1 [Not candidate version]

E: Package 'nginx' has no installation candidate

哎呀!请帮忙!

答案1

几天前我遇到了类似的问题,当 APT 无法识别您尝试安装的软件包时就会发生这种情况,请尝试转到 Ubuntu 软件和更新并确保您正在从主服务器下载,然后尝试:

 sudo apt-get -y --allow-unauthenticated install nginx

相关内容