您可以使用 Ondřej Surý 发布的软件包,请参阅 deb.sury.org
打开终端并运行以下命令:
apt-get install apt-transport-https lsb-release ca-certificates
获取 gpg 密钥:
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
艺术
curl https://packages.sury.org/php/apt.gpg | apt-key add -
将新存储库添加到源:
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
安装 PHP5.6
apt-get update
apt-get install php5.6
要在 PHP 版本之间切换:
update-alternatives --config php
示例输出:
----------------------------------------------------------
* 0 /usr/bin/php7.0 70 mode automatique
1 /usr/bin/php5.6 56 mode manuel
2 /usr/bin/php7.0 70 mode manuel