在 Linode 服务器 Debian 9 上为 php5.6 安装 GD Library 时依赖关系中断

Broken dependencies while installing GD Library for php5.6 on Linode server Debian 9

我想在 Linode Server Debian 9

上为 php5.6 安装 GD 库

我运行apt-get install php5.6-gd

输出为:

php5.6-gd : Depends: libgd3 (>= 2.1.1) but it is not going to be installed

然后我尝试安装那个包 apt-get install libgd3 输出是:

 libgd3 : Depends: libfontconfig1 (>= 2.11.94) but 2.11.0-6.7+b1 is to be installed
 Depends: libjpeg8 (>= 8c) but it is not installable

我尝试通过 运行ning 命令安装上述版本 apt-get install libfontconfig1=2.11.94

输出为:

Version '2.11.94' for 'libfontconfig1' was not found

我通过 运行ning 检查了 libfontconfig1 包的可用版本:

apt-cache policy libfontconfig1

输出为:

libfontconfig1:

 Installed: 2.11.0-6.7+b1
 Candidate: 2.11.0-6.7+b1
 Version table:
2.11.0-6.7+b1 500
       500 http://mirrors.linode.com/debian stretch/main amd64 Packages
       100 /var/lib/dpkg/status

我没有找到可用的 (>= 2.11.94) 版本。

cat /etc/apt/sources.list

的输出
# deb http://mirrors.linode.com/debian/ stretch main

deb http://mirrors.linode.com/debian/ stretch main
deb-src http://mirrors.linode.com/debian/ stretch main

deb http://security.debian.org/debian-security stretch/updates main
deb-src http://security.debian.org/debian-security stretch/updates main

deb http://ftp.de.debian.org/debian stretch main

cat 的输出/etc/apt/sources.list.d/*enter image description here

在 debian stretch 上,您的 /etc/apt/sources.list.d/php.list 应该只包含以下行:

deb https://packages.sury.org/php/ stretch main

您需要取消注释以上行(删除 #)并禁用其他 ppa(您不需要它们)。

启用时依赖问题来自巧妙的 ppa。要解决您的问题,请打开终端然后 运行 以下命令:

rm /etc/apt/sources.list.d/*
apt install apt-transport-https lsb-release ca-certificates curl
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
curl https://packages.sury.org/php/apt.gpg | apt-key add -
apt update
apt upgrade
apt dist-upgrade
apt install php5.6

使用 update-alternatives --config php 在 php 版本之间切换。

问题是 http://ppa.launchpad.net/ondrej/php/ubuntu 包含有冲突的 libgd3 版本。

vagrant@localhost:~$ sudo apt-cache policy libgd3
libgd3:
  Installed: (none)
  Candidate: 2.2.5-3+ubuntu16.04.1+deb.sury.org+1
  Version table:
     2.2.5-3+ubuntu16.04.1+deb.sury.org+1 500
        500 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 Packages
     2.2.4-2+deb9u2 500
        500 http://deb.debian.org/debian stretch/main amd64 Packages
        500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages

您需要从官方存储库安装版本,如下所示:

vagrant@localhost:~$ sudo apt-get install libgd3=2.2.4-2+deb9u2

希望对您有所帮助。