install php-gd ext on Debian

tomasnikl picture tomasnikl · Mar 23, 2019 · Viewed 8.1k times · Source

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?

Answer

Joey picture Joey · Mar 24, 2019

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