最近我将 Ubuntu 从 20 升级到 22。我在 Ubuntu 20 中使用 Php7.4 和 Apache 服务器。升级到Ubuntu 22后,Php自动升级到8.1。之后,我也在我的系统中安装了 Php7.4。我可以使用以下命令切换 PHP 版本:
sudo update-alternatives --config php
Run Code Online (Sandbox Code Playgroud)
如果我使用终端,我可以使用php -v. 但我无法在apache中使用Php7.4。我正在尝试使用以下命令进行安装:
sudo apt-get install libapache2-mod-php7.4
Run Code Online (Sandbox Code Playgroud)
但它给了我以下错误:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libapache2-mod-php7.4 : Depends: php8.1-common (= 8.1.2-1ubuntu2) but 8.1.5-1+ubuntu22.04.1+deb.sury.org+1.1 is to be installed
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)
如果我再次尝试使用以下命令在 apache 中激活 Php7.4:
sudo a2enmod php7.4
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
ERROR: Module php7.4 does not exist!
Run Code Online (Sandbox Code Playgroud)
现在我如何在我的 Apache 中使用 Php7.4?请注意,Apache 已安装在 Ubuntu 20 中。
小智 6
该问题似乎与Ubuntu 22 * 不包括有关php 7.4,您需要添加外部存储库。
请尝试以下操作:
sudo apt update && sudo apt upgradesudo add-apt-repository ppa:ondrej/php -ysudo apt install php7.4sudo apt install php7.4-{cli,common,curl,zip,gd,mysql,xml,mbstring,json,intl}sudo update-alternatives --config phpphp 7.4.sudo apt-get install libapache2-mod-php7.4现在它会起作用了!
来源。
我遇到了完全相同的问题,这对我有用。
| 归档时间: |
|
| 查看次数: |
12395 次 |
| 最近记录: |