如何解决在 Ubuntu 20 上安装 PHP 8.x 时出现的错误

如何解决在 Ubuntu 20 上安装 PHP 8.x 时出现的错误

我正在尝试安装 PHP 8.x,但我一次又一次地陷入困境

因此,为了安装 PHP,我认为我需要有ppa:ondrej/php存储库。我在运行

sudo add-apt-repository ppa:ondrej/php

我用这个答案解决了这个问题->https://askubuntu.com/a/1488524

现在,当我运行此命令来安装 PHP 8.0 时(我也尝试过 8.1 和 8.2,但后来卡在同一点)

sudo apt install php8.0 -y

我收到这个错误

The following packages have unmet dependencies:
 php8.0 : Depends: libapache2-mod-php8.0 but it is not going to be installed or
                   php8.0-fpm but it is not going to be installed or
                   php8.0-cgi but it is not going to be installed

然后我尝试跑步

sudo apt install libapache2-mod-php8.1

我仍然面临一个错误

The following packages have unmet dependencies:
 libapache2-mod-php8.1 : Depends: php8.1-cli but it is not going to be installed
                         Depends: libpcre2-8-0 (>= 10.38) but 10.34-7ubuntu0.1 is to be installed

我再次尝试逃跑

sudo apt install php8.1-cli

但是我面临这个错误

The following packages have unmet dependencies:
 php8.1-cli : Depends: libpcre2-8-0 (>= 10.38) but 10.34-7ubuntu0.1 is to be installed

这是我最终陷入困境的地方。我试过跑

sudo apt install libpcre2-8-0

但它说这是最新版本

libpcre2-8-0 is already the newest version (10.34-7ubuntu0.1).

我已经检查过了,我认为新版本一直可用到 10.42 ->https://packages.debian.org/sid/libpcre2-8-0

但我现在不知道如何继续安装最新版本

我甚至尝试将其完全删除,然后再次安装

sudo apt remove libpcre2-8-0 -f

但徒劳无功

The following packages have unmet dependencies:
 libnode64 : Depends: libicu66 (>= 66.1-1~) but it is not going to be installed
             Depends: libssl1.1 (>= 1.1.1) but it is not going to be installed
 libxml2 : Depends: libicu66 (>= 66.1-1~) but it is not going to be installed
 nginx : Depends: nginx-core (< 1.18.0-0ubuntu1.4.1~) but it is not going to be installed or
                  nginx-full (< 1.18.0-0ubuntu1.4.1~) but it is not going to be installed or
                  nginx-light (< 1.18.0-0ubuntu1.4.1~) but it is not going to be installed or
                  nginx-extras (< 1.18.0-0ubuntu1.4.1~) but it is not going to be installed
         Depends: nginx-core (>= 1.18.0-0ubuntu1.4) but it is not going to be installed or
                  nginx-full (>= 1.18.0-0ubuntu1.4) but it is not going to be installed or
                  nginx-light (>= 1.18.0-0ubuntu1.4) but it is not going to be installed or
                  nginx-extras (>= 1.18.0-0ubuntu1.4) but it is not going to be installed

有其他人遇到过这个问题吗?从这一点开始,我该如何继续调试和解决问题?任何帮助都非常感谢 :)

答案1

终于找到了解决办法

我不得不跑

sudo apt policy libpcre2-8-0

输出表明了这一点

libpcre2-8-0:
  Installed: 10.34-7ubuntu0.1
  Candidate: 10.34-7ubuntu0.1
  Version table:
     10.42-3+ubuntu20.04.1+deb.sury.org+1 500
        500 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 Packages
 *** 10.34-7ubuntu0.1 1001
       1001 http://us-west-2.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
       1001 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
        100 /var/lib/dpkg/status
     10.34-7 1001
       1001 http://us-west-2.ec2.archive.ubuntu.com/ubuntu focal/main amd64 Packages
[email protected](dev) ➜  ~ sudo apt install libpcre2-8-0=10.40-1+0~20220713.16+debian10~1.gbpb6cec5

所以我选择了该10.42-3+ubuntu20.04.1+deb.sury.org+1版本并像这样安装它

sudo apt install libpcre2-8-0=10.42-3+ubuntu20.04.1+deb.sury.org+1

并且成功了。现在我可以sudo apt install php8.1成功运行了 :)

相关内容