在 ubuntu 中安装 php 时出错

在 ubuntu 中安装 php 时出错

我正在尝试在我的 ubuntu 系统中安装 php,我已经安装了 apache 和 mysql,但是我无法使用以下命令安装 php

sudo apt install php libapache2-mod-php

我收到以下错误:

(Reading database ... 489 files and directories currently installed.)
Preparing to unpack .../libapache2-mod-php_2%3a7.3+69+ubuntu18.10.1+deb.sury.org+2+php7.3_all.deb ...
Unpacking libapache2-mod-php (2:7.3+69+ubuntu18.10.1+deb.sury.org+2+php7.3) ...
Setting up php7.3-common (7.3.3-1+ubuntu18.10.1+deb.sury.org+1) ...
dpkg: error processing package php7.3-common (--configure):
 installed php7.3-common package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of php7.3-opcache:
 php7.3-opcache depends on php7.3-common (= 7.3.3-1+ubuntu18.10.1+deb.sury.org+1); however:
  Package php7.3-common is not configured yet.

dpkg: error processing package php7.3-opcache (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libapache2-mod-php7.3:
 libapache2-mod-php7.3 depends on php7.3-common (= 7.3.3-1+ubuntu18.10.1+deb.sury.org+1); however:
  Package php7.3-common is not configured yet.
 libapache2-mod-php7.3 depends on php7.3-opcache; however:
  Package php7.3-opcache is not configured yet.

dpkg: error processing package libapache2-mod-php7.3 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          No apport report written because the error message indicates its a followup error from a previous failure.
                                                    dpkg: dependency problems prevent configuration of php7.3-cli:
 php7.3-cli depends on php7.3-common (= 7.3.3-1+ubuntu18.10.1+deb.sury.org+1); however:
  Package php7.3-common is not configured yet.
 php7.3-cli depends on php7.3-opcache; however:
  Package php7.3-opcache is not configured yet.

dpkg: error processing package php7.3-cli (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of php7.3-readline:
 php7.3-readline depends on php7.3-common (= 7.3.3-1+ubuntu18.10.1+deb.sury.org+1); however:
  Package php7.3-common is not configured yet.

dpkg: error processing package php7.3-readline (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of php7.3:
 php7.3 depends on libapache2-mod-php7.3 | php7.3-fpm | php7.3-cgi; however:
  Package libapache2-mod-php7.3 is not configured yet.
  Package php7.3-fpm is not installed.
  Package php7.3-cgi is not installed.
 php7.3 depends on php7.3-common; however:
  Package php7.3-common is not configured yet.

dpkg: error processing package php7.3 (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of php7.3-json:
 php7.3-json depends on php7.3-common (= 7.3.3-1+ubuntu18.10.1+deb.sury.org+1); however:
  Package php7.3-common is not configured yet.

dpkg: error processing package php7.3-json (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of libapache2-mod-php:
 libapache2-mod-php depends on libapache2-mod-php7.3; however:
  Package libapache2-mod-php7.3 is not configured yet.

dpkg: error processing package libapache2-mod-php (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of php:
 php depends on php7.3; however:
  Package php7.3 is not configured yet.

dpkg: error processing package php (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 php7.3-common
 php7.3-opcache
 libapache2-mod-php7.3
 php7.3-cli
 php7.3-readline
 php7.3
 php7.3-json
 libapache2-mod-php
 php
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

虽然这个答案晚了两年,但当目录dpkg中有损坏/不完整的安装残留时,可能会发生此问题info。您通常可以这样解决问题:

sudo rm /var/lib/dpkg/info/php*
sudo dpkg --configure -D 777 php
sudo apt -f install

然后再来说libapache2-mod-php

sudo rm /var/lib/dpkg/info/libapache2-mod-php*
sudo dpkg --configure -D 777 libapache2-mod-php
sudo apt -f install

这是在做什么:

  • 删除受影响软件包的.list和文件.md5sums/var/lib/dpkg/info
  • 设置dpkg为调试模式,这样,如果构建失败,您将有更具体的数据可以使用,从而更容易找出原因为什么无法安装该软件包
  • 强制安装软件包(尽可能合理)

希望这可以为将来遇到此类问题的人提供帮助。

相关内容