在 ubuntu 17.04 中安装 php 7.2 时出错

2022-08-30 19:29:59

我在运行以下命令时收到此错误

sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm   

正在读取状态信息...做

E: Unable to locate package php7.2
E: Couldn't find any package by glob 'php7.2'
E: Couldn't find any package by regex 'php7.2'
E: Unable to locate package php7.2-common
E: Couldn't find any package by glob 'php7.2-common'
E: Couldn't find any package by regex 'php7.2-common'
E: Unable to locate package php7.2-cli
E: Couldn't find any package by glob 'php7.2-cli'
E: Couldn't find any package by regex 'php7.2-cli'
E: Unable to locate package php7.2-fpm
E: Couldn't find any package by glob 'php7.2-fpm'
E: Couldn't find any package by regex 'php7.2-fpm'

答案 1

您需要手动添加 才能在 Ubuntu 17 上安装 PHP7.2。ondrej PPA

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2

或者,通过克隆git存储库从源代码编译它,签出您想要的版本,进行安装

有关从源代码编译 PHP 的更多信息,请查看如何从源代码构建/编译 PHP


答案 2

我遇到了类似的问题。此页面帮助我解决了它。https://tecadmin.net/install-php-debian-9-stretch/

具体来说,在 php 安装之前运行这些命令

sudo apt install ca-certificates apt-transport-https

wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -

echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list


推荐