无法在Debian 9 (Stretch)上安装PHP 7.2

4

我在Debian Stretch上添加了一个软件源以安装PHP 7.2。

sudo apt install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update

但是当我运行apt update时,出现错误:
E: The repository 'https://packages.sury.org/php stretch Release' does not have a Release file.

据我所知,问题出在我的环境上。 但是我无法确定问题出在哪里。 PS: 我的/etc/apt/sources.list文件:
# deb http://ftp.de.debian.org/debian/ jessie main
# deb http://ftp.de.debian.org/debian/ buster main
deb http://ftp.de.debian.org/debian/ stretch main
deb http://ftp.us.debian.org/debian/ stretch main contrib non-free
deb-src http://ftp.us.debian.org/debian/ stretch main contrib non-free
deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb http://ftp.by.debian.org/debian/ stretch-updates main
deb http://mirror.yandex.ru/debian/ stretch-backports main contrib non-free
deb http://ftp.debian.org/debian/ stretch-backports main
deb http://dl.winehq.org/wine-builds/debian/ stretch main

在 /etc/apt/sources.list.d 目录下有一个名为 php.list 的文件,其中包含以下内容:
deb https://packages.sury.org/php/ stretch main
3个回答

17

由于Debian 9 stretch不再支持来自sury.org的任何php版本,因此在此提供一个解决方案。您可以从sury.org的备份中找到它。下载任何php版本(包括php8.1)。花费了我太长时间才找到它!祝你使用愉快。

echo "deb https://debian.octopuce.fr/snapshots/sury-php/20220630/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
wget -qO - https://debian.octopuce.fr/sury-php/apt.gpg | sudo apt-key add -
apt update

这是Debian 9的唯一正确解决方案!非常感谢。 - hieroshima
哇,我找了好几天的解决方案,来在Debian9上获得php7.4,这是唯一有效的一个!谢谢! - omega1

7
如果有帮助的话,以下是我几个小时前在Debian Stretch上安装php 7.2时采取的确切步骤(与您的步骤大致相似):
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
cd /etc/apt/sources.list.d/
sudo mv ondrej-ubuntu* /tmp
sudo apt -y update
sudo apt install php7.2

1
非常感谢,所以我们应该永远不要将Ubuntu和Debian混合使用吗? - javier_domenech

1
如果您在/etc/apt/sources.list.d/目录中找到以下列出的文件,请删除它们并重试:
ondrej-ubuntu-apache2-cosmic.list
ondrej-ubuntu-php-cosmic.list
ondrej-ubuntu-php-cosmic.list.save

感谢您的回答。 在我的 /etc/apt/sources.list.d/ 目录下没有这样的文件。 - tropic

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接