降级PHP版本

abu*_*abu 0 php linux-mint version

我在 Linux Mint 19.1 中运行 PHP 8。现在我需要运行 PHP 7。我该怎么做?

在此输入图像描述

Sta*_*Cat 5

由于 Mint 是 Debian/Ubuntu 的衍生版本,因此以下内容应该有效:

sudo update-alternatives --config php
Run Code Online (Sandbox Code Playgroud)

然后,您的系统应该显示系统上安装的 PHP 版本的列表,您可以手动选择一个版本作为默认版本,如下所示:

There are 5 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php8.0   80        auto mode
  1            /usr/bin/php7.0   70        manual mode
  2            /usr/bin/php7.2   72        manual mode
  3            /usr/bin/php7.3   73        manual mode
  4            /usr/bin/php7.4   74        manual mode
Press <enter> to keep the current choice[*], or type selection number:
Run Code Online (Sandbox Code Playgroud)

如果您还需要 Apache 与替代 PHP 版本一起运行,您可以使用以下命令来执行此操作(例如从 PHP 8.0 切换到 PHP 7.4):

sudo a2dismod php80
sudo a2enmod php74
sudo systemctl restart apache2
Run Code Online (Sandbox Code Playgroud)

正如我从您的问题中看到的那样,由于依赖性问题,您的 PHP 7.4 安装未完成,只有当此问题得到解决并且所有必需的 PHP 7.4 软件包都已安装时,上述过程才会起作用。