在Debian上安装php-gd ext

时间:2019-03-23 21:18:33

标签: debian php-7.2 php-gd

我无法在服务器上安装php-gd扩展名。

我有php 7.2:

PHP 7.2.10-1+0~20181001133426.7+jessie~1.gbpb6e829 (cli) (built: Oct  1 2018 13:50:53) ( NTS )

和debian 8 Linux:

Debian GNU/Linux 8

安装GD扩展程序的命令:

sudo apt-get install php7.2-gd

和结果:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libc-ares2 libnfsidmap2 libpcre16-3 libpcre32-3 libuuid-perl libv8-3.14.5 php-http-request php-mail-mimedecode php-net-dime php-net-url
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
  php7.2-gd
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 27.5 kB of archives.
After this operation, 186 kB of additional disk space will be used.
Get:1 https://packages.sury.org/php/ jessie/main php7.2-gd amd64 7.2.10-1+0~20181001133426.7+jessie~1.gbpb6e829 [27.5 kB]
Err https://packages.sury.org/php/ jessie/main php7.2-gd amd64 7.2.10-1+0~20181001133426.7+jessie~1.gbpb6e829
  HttpError404
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php7.2/php7.2-gd_7.2.10-1+0~20181001133426.7+jessie~1.gbpb6e829_amd64.deb  HttpError404

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

请问如何解决它的任何想法?

2 个答案:

答案 0 :(得分:0)

php-7.2-gd软件包在Debian仓库中尚不可用。但是通过这种方式,您仍然可以安装它(以下某些命令可能需要sudo):


首先,将密钥下载到软件包源:

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

然后在.list中创建一个/etc/apt/sources.list.d/文件:

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

然后运行更新和升级:

# apt update && apt upgrade

现在您可以安装php7.2-gd

# apt install php7.2-gd

答案 1 :(得分:0)

运行以下命令:

apt update
apt upgrade
apt install php7.2-gd

错误“无法获取”,因为apt将尝试使用过时的数据库从php7.2-gd存储库中下载/安装sury的旧(已删除)版本。

08-Mar-2019中,php7.2-gd_7.2.10-1+0~20181001133426.7+jessie~1.gbpb6e829_amd64.deb已更新为新版本php7.2-gd_7.2.16-1+0~20190307202206.17+jessie~1.gbpa7be82_amd64.deb,旧版本已删除,这就是apt无法检索有关旧软件包的信息的原因。

OndřejSurý存储库已正确配置,apt未显示任何错误。