问题
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?
回答1:
The php-7.2-gd
package isn't available in Debian repositories (yet). But this way you can install it anyway:
First, download the key to the package source:
$ sudo wget -q -O- https://packages.sury.org/php/apt.gpg | apt-key add -
Then create a .list
file in /etc/apt/sources.list.d/
:
$ sudo echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list
Then run apt update
and apt upgrade
:
$ sudo apt update && apt upgrade
Now you're able to install the php7.2-gd package:
$ sudo apt install php7.2-gd
回答2:
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.
来源:https://stackoverflow.com/questions/55318499/install-php-gd-ext-on-debian