3

I'm not able to install php-gd extension on my server.

I have php 7.2:

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

and debian 8 linux:

Debian GNU/Linux 8

command to install GD extension:

sudo apt-get install php7.2-gd

and result:

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?

any ideas how to fix it please?

tomasnikl
  • 83
  • 1
  • 2
  • 10

2 Answers2

8

The php-7.2-gd package isn't available in Debian repositories (yet). But that doesn't matter, of course you can install it anyway. There's a great website named DEB.SURY.ORG that packages different software into Debian and Ubuntu (especially PHP packages).

First, download the key to the package source:

$ sudo curl -s https://packages.sury.org/php/apt.gpg | sudo apt-key add -

Then create a .list file in /etc/apt/sources.list.d/:

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

Then update and upgrade your distro:

$ sudo apt update -y && sudo apt dist-upgrade -y

Now you should be able to install the php7.2-gd package by running:

$ sudo apt install php7.2-gd
Joey
  • 1,436
  • 2
  • 19
  • 33
  • 1
    More portable execution: ```curl -s https://packages.sury.org/php/apt.gpg | sudo apt-key add -``` – viktorkho Feb 11 '20 at 13:36
  • 1
    Doesn't work with buster: ```Package php7.2-gd is not available, but is referred to by another package.``` – viktorkho Feb 11 '20 at 14:15
  • @viktorkho Sorry, you're right. I have updated my answer. **NOTE**: At that time `buster` was the codename for `debian-testing`, and that was the issue. Now, `buster` has become `debian-stable` and so, the above answer should provide an option how to get the `php7.2-gd` package installed. Tested on Debian Buster (stable), works. – Joey Apr 17 '20 at 02:26
-1

Run the following commands:

apt update
apt upgrade
apt install php7.2-gd

The error "Failed to fetch" because apt will try to use an outaded database to download/install an old (removed) version of php7.2-gd from sury repository.

In 08-Mar-2019 the php7.2-gd_7.2.10-1+0~20181001133426.7+jessie~1.gbpb6e829_amd64.deb is updated to a new version php7.2-gd_7.2.16-1+0~20190307202206.17+jessie~1.gbpa7be82_amd64.deb, the old version is removed, that's why apt fail to retrieve the information about the old package.

The Ondřej Surý repository is already configured correctly, apt doesn't show any error.

GAD3R
  • 4,317
  • 1
  • 23
  • 34