从 18.04 升级到 ubuntu 20.04 后无法安装 php

从 18.04 升级到 ubuntu 20.04 后无法安装 php

我已经将 ubuntu 18.04 版本升级到 20.04。删除了之前安装的 PHP。然后我运行

sudo apt install php-cli

但我遇到以下错误:

The following packages have unmet dependencies:
 php7.4-cli : Depends: php7.4-common (= 7.4.3-4ubuntu2.4) but 7.4.8-1+ubuntu18.04.1+deb.sury.org+3 is to be installed
              Depends: php7.4-json but it is not going to be installed
              Depends: php7.4-opcache but it is not going to be installed
              Depends: php7.4-readline but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

所以我怀疑7.4.8-1+ubuntu18.04.1+deb.sury.org+3软件包仍然处于活动状态?我检查了/etc/apt/sources.list目录/etc/apt/sources.list.d/,没有找到与该软件包匹配的任何源。

我还应该去哪里寻找?

编辑

apt policy php7.4-common

php7.4-common:
  Installed: 7.4.8-1+ubuntu18.04.1+deb.sury.org+3
  Candidate: 7.4.8-1+ubuntu18.04.1+deb.sury.org+3
  Version table:
 *** 7.4.8-1+ubuntu18.04.1+deb.sury.org+3 100
        100 /var/lib/dpkg/status
     7.4.3-4ubuntu2.4 500
        500 http://bd.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
     7.4.3-4ubuntu1 500
        500 http://bd.archive.ubuntu.com/ubuntu focal/main amd64 Packages

答案1

你卸载了php,但没有卸载它的依赖项,所以仍然有残留ppa(我猜是ppa:ondrej/php)。

尝试一下autoremove,可能已经足够了:

sudo apt autoremove

如果没有,您可以手动卸载有问题的软件包:

sudo apt remove php7.4-common

如果这还不够的话,ppa 再次添加并删除可能会有所帮助ppa-purge

sudo add-apt-repository ppa:ondrej/php
sudo apt install ppa-purge
sudo ppa-purge ppa:ondrej/php

相关内容