15.10 升级到 16.04 后 PHP 崩溃

15.10 升级到 16.04 后 PHP 崩溃

我意外地升级了我的系统而不是直接进行更新,而且我的 moodle 无法工作,因为 PHP 乱了。

它告诉我有未满足的依赖关系,并且 PHP5-cli 存在问题。

sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.19.0-18 linux-headers-3.19.0-18-generic linux-headers-3.19.0-26
  linux-headers-3.19.0-26-generic linux-headers-3.19.0-30 linux-headers-3.19.0-30-generic
  linux-headers-3.19.0-31 linux-headers-3.19.0-31-generic linux-headers-3.19.0-39
  linux-headers-3.19.0-39-generic linux-headers-3.19.0-42 linux-headers-3.19.0-42-generic
  linux-headers-3.19.0-43 linux-headers-3.19.0-43-generic linux-headers-3.19.0-47
  linux-headers-3.19.0-47-generic linux-headers-3.19.0-49 linux-headers-3.19.0-49-generic
  linux-headers-4.2.0-30 linux-headers-4.2.0-30-generic linux-image-3.19.0-18-generic
  linux-image-3.19.0-26-generic linux-image-3.19.0-30-generic linux-image-3.19.0-31-generic
  linux-image-3.19.0-39-generic linux-image-3.19.0-42-generic linux-image-3.19.0-43-generic
  linux-image-3.19.0-47-generic linux-image-3.19.0-49-generic linux-image-4.2.0-30-generic
  linux-image-extra-3.19.0-18-generic linux-image-extra-3.19.0-26-generic
  linux-image-extra-3.19.0-30-generic linux-image-extra-3.19.0-31-generic
  linux-image-extra-3.19.0-39-generic linux-image-extra-3.19.0-42-generic
  linux-image-extra-3.19.0-43-generic linux-image-extra-3.19.0-47-generic
  linux-image-extra-3.19.0-49-generic linux-image-extra-4.2.0-30-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  pkg-php-tools
Suggested packages:
  dh-make
The following packages will be REMOVED:
  libapache2-mod-php5
The following packages will be upgraded:
  pkg-php-tools
1 upgraded, 0 newly installed, 1 to remove and 318 not upgraded.
15 not fully installed or removed.
Need to get 0 B/38.2 kB of archives.
After this operation, 10.2 MB disk space will be freed.
Do you want to continue? [Y/n] y
WARNING: The following packages cannot be authenticated!
  pkg-php-tools
Install these packages without verification? [y/N] y
(Reading database ... 560010 files and directories currently installed.)
Removing libapache2-mod-php5 (5.6.11+dfsg-1ubuntu3.2) ...
ERROR: Module php5 does not exist!
dpkg: error processing package libapache2-mod-php5 (--remove):
 subprocess installed pre-removal script returned error exit status 1
Errors were encountered while processing:
 libapache2-mod-php5
E: Sub-process /usr/bin/dpkg returned an error code (1)

我该如何修复我的 php?我似乎无法修复依赖项。


运行时sudo dpkg --configure -a我遇到很多依赖问题 - 未配置。

sudo apt-get install -f我明白了

The following additional packages will be installed:
  pkg-php-tools
Suggested packages:
  dh-make
The following packages will be REMOVED:
  libapache2-mod-php5
The following packages will be upgraded:
  pkg-php-tools
1 upgraded, 0 newly installed, 1 to remove and 319 not upgraded.
15 not fully installed or removed.
Need to get 0 B/38.2 kB of archives.
After this operation, 10.2 MB disk space will be freed.
Do you want to continue? [Y/n] y
WARNING: The following packages cannot be authenticated!
  pkg-php-tools
Install these packages without verification? [y/N] y
(Reading database ... 560010 files and directories currently installed.)
Removing libapache2-mod-php5 (5.6.11+dfsg-1ubuntu3.2) ...
ERROR: Module php5 does not exist!
dpkg: error processing package libapache2-mod-php5 (--remove):
 subprocess installed pre-removal script returned error exit status 1
Errors were encountered while processing:
 libapache2-mod-php5
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我遇到了同样的问题,我升级到 16.04 后,尝试通过安装基本 LAMP 包来运行 joomla,这时就开始发生这种情况。
无法安装任何包,也无法删除libapache2-mod-php5

删除 libapache2-mod-php5
错误:模块 php5 不存在!

经过一番 Google 搜索和思考后,我猜测 Apache 仍在使用 php5 是我的问题的一部分。

我不确定这是否是解决问题的正确方法,但我设法通过执行以下操作解决了此问题:

cd /etc/apache2/mods-enabled
sudo mv php5.conf php5.conf.old
sudo mv php5.load php5.load.old
sudo apt-get purge libapache2-mod-php5
sudo apt-get update
sudo apt-get upgrade

这解决了问题,我可以再次愉快地安装和删除软件。

也许有人比我聪明,可以解释为什么这样做有效,或者提出一个更优雅/更合适的解决方案。

无论如何,我希望这会有所帮助。

答案2

问题是你不再使用 PHP 5,而是运行 PHP7。你可能需要为新的 PHP7 更新一些 PHP 插件和文件。php.ini 现在位于 /etc/php/7.0 而不是 /etc/php5。你可能需要更改 apache 或 moodle 中的内容以反映此更改

相关内容