无法使用 WHM/cPanel 在 Ubuntu 22.04 服务器上安装 PHP 7.x – 缺少软件包

问题描述 投票:0回答:1

我正在使用 Ubuntu 22.04 设置服务器,并使用 WHM/cPanel 来管理多个帐户和配置。我的目标是在服务器上安装 PHP 7.4(或 PHP 7.3 等早期版本),因为我的一些应用程序与 PHP 8.x 不兼容。问题是,每当我尝试安装 PHP 7.x 时,都会遇到错误,指出软件包丢失、过时或不可用。

服务器配置

  • 操作系统:Ubuntu Server 22.04 LTS
  • 管理软件:WHM/cPanel
  • PHP 要求: PHP 7.4、PHP 7.3

问题详情

当我尝试为我的一个帐户配置 PHP 7.x 时,我第一次通过 WHM 注意到这个问题。我意识到默认情况下无法安装 PHP 7.x 软件包。然后我尝试了多种解决方案来手动安装 PHP 7.x,但都失败了。

到目前为止我已经尝试过的事情

  1. 添加了 SURY PPA 存储库
    我添加了 ppa:ondrej/php 存储库,据说其中包含较旧的 PHP 版本(包括 7.4 和 7.3)。使用的命令:

    sudo apt update
    sudo add-apt-repository ppa:ondrej/php
    sudo apt update
    sudo apt install -y php7.4 php7.4-cli php7.4-fpm php7.4-mysql
    

    结果: 安装失败,并出现错误,例如“软件包 php7.4-common 不可用,但被另一个软件包引用。”

  2. 尝试直接下载

    .deb
    软件包
    我手动下载了各个 PHP 7.4
    .deb
    软件包及其依赖项,尝试使用
    dpkg
    安装它们。手动安装所需的依赖项后,我仍然遇到了包兼容性问题。

  3. 尝试通过 Docker 安装 PHP 7.x(但这并不理想)
    我能够在 Docker 容器中运行 PHP 7.4,但理想情况下,我想避免使用 Docker 并直接在服务器上安装 PHP 7.4,以便使用 WHM 更轻松地进行管理。

  4. 检查并重新添加依赖项
    在遇到像

    libicu70
    这样的包缺少依赖项后,我尝试手动安装依赖项,但仍然不允许安装 PHP 7.x。

错误信息

尝试安装 php7.x 时,反复出现的错误是:

在此输入图片描述

root@srv:/# sudo apt install -y php7.3 php7.3-cli php7.3-fpm php7.3-common php7.3-mysql php7.3-zip php7.3-gd php7.3-mbstring php7.3-curl php7.3-xml php7.3-bcmath
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package php7.3-common is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.3-cli is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.3-mbstring is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.3-xml is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.3 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.3-fpm is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.3-bcmath is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.3-curl is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.3-gd is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.3-mysql is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.3-zip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php7.3' has no installation candidate
E: Package 'php7.3-cli' has no installation candidate
E: Package 'php7.3-fpm' has no installation candidate
E: Package 'php7.3-common' has no installation candidate
E: Package 'php7.3-mysql' has no installation candidate
E: Package 'php7.3-zip' has no installation candidate
E: Package 'php7.3-gd' has no installation candidate
E: Package 'php7.3-mbstring' has no installation candidate
E: Package 'php7.3-curl' has no installation candidate
E: Package 'php7.3-xml' has no installation candidate
E: Package 'php7.3-bcmath' has no installation candidate
root@srv:/#

问题

有没有办法强制 Ubuntu 22.04 安装 PHP 7.x?我是否错过了直接在此版本的 Ubuntu 上安装 PHP 7.3 或 7.4 的任何步骤或替代方法?或者,有没有办法设置 WHM 以使用自定义源中的 PHP 7.x?


PS:我首先尝试安装php7.4,当我根本无法安装时,我尝试了php7.3,但我得到了相同的结果,并且这个问题中显示的结果来自安装php7。 3

PS: 从技术上讲,我可以通过使用较旧的 Ubuntu 版本创建新磁盘来解决此问题,但这需要我重新配置整个服务器,包括所有客户端的 WHM 和 cPanel,这是非常耗时的。老实说,我觉得这不应该是一个问题,而且我不想简单地认为这是无法解决的。

PS: 我对服务器配置相当陌生,所以我在这方面的知识有限。我尝试完全按照描述遵循每条建议,但我可能错过或误解了某些内容。任何指导将不胜感激!

php ubuntu php-7 ubuntu-22.04 whm
1个回答
0
投票

对于您的特殊情况,如果您想在 Ubuntu 22.04 上安装 php7.4,您需要执行以下步骤:

sudo apt update
sudo apt upgrade

sudo apt install software-properties-common curl gnupg2 wget -y

之后,添加存储库

sudo add-apt-repository ppa:ondrej/php
sudo apt update

现在您应该能够安装 PHP 7.x(和相关模块)

© www.soinside.com 2019 - 2024. All rights reserved.