unable to enable php-gmp for php7.4 with ddev

4.8k views Asked by At

Because of this error message the requested PHP extension gmp is missing from your system I want to add the gmp extension to php 7.4 using DDEV.

First I made a .ddev/php/ folder and created a 99-gmp.ini file. Second I added extension=php_gmp.so to 99-gmp.ini

I ssh login ddev ssh and run:

sudo apt install php-gmp

sudo apt-get install php-gmp

sudo apt-get install php7.4-gmp And tried a few variants but the package isn't found

searching for apt search php-gmp results in:

Reading package lists... DoneBuilding dependency tree Reading state information... Done E: Unable to locate package php-gmp

apt search gmp results in 3 packages, all installed already:

Full Text Search... Done

libgmp10/now 2:6.1.2+dfsg-4 amd64 [installed,local] Multiprecision arithmetic library

libhogweed4/now 3.4.1-1 amd64 [installed,local] low level cryptographic library (public-key cryptos)

libnettle6/now 3.4.1-1 amd64 [installed,local] low level cryptographic library (symmetric and one-way cryptos)

Looking for php7.4 extentions: apt search php7.4 For some reason gmp isn't found?

Sorting... Done Full Text Search... Done

libapache2-mod-php7.4/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] server-side, HTML-embedded scripting language (Apache 2 module)

php7.4-bcmath/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] Bcmath module for PHP

php7.4-bz2/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] bzip2 module for PHP

php7.4-cgi/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] server-side, HTML-embedded scripting language (CGI binary)

php7.4-cli/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] command-line interpreter for the PHP scripting language

php7.4-common/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] documentation, examples and common module for PHP

php7.4-curl/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] CURL module for PHP

php7.4-fpm/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] server-side, HTML-embedded scripting language (FPM-CGI binary)

php7.4-gd/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] GD module for PHP

php7.4-intl/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] Internationalisation module for PHP

php7.4-json/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] JSON module for PHP

php7.4-ldap/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] LDAP module for PHP

php7.4-mbstring/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] MBSTRING module for PHP

php7.4-mysql/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] MySQL module for PHP

php7.4-opcache/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] Zend OpCache module for PHP

php7.4-pgsql/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] PostgreSQL module for PHP

php7.4-phpdbg/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] server-side, HTML-embedded scripting language (PHPDBG binary)

php7.4-readline/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] readline module for PHP

php7.4-soap/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] SOAP module for PHP

php7.4-sqlite3/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] SQLite3 module for PHP

php7.4-xml/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] DOM, SimpleXML, XML, and XSL module for PHP

php7.4-xmlrpc/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] XMLRPC-EPI module for PHP

php7.4-zip/now 7.4.8-1+0~20200713.23+debian10~1.gbpb2c15c amd64 [installed,local] Zip module for PHP

Project Information

PHP version: 7.4 OS: Debian 10 NFS mount enabled: false Database type: mariadb MariaDB version: 10.3

1

There are 1 answers

2
Nico Haase On BEST ANSWER

Usually, you should add packages through adding webimage_extra_packages to your configuration (see the documentation):

webimage_extra_packages: [php7.4-gmp]

On restarting the containers using ddev restart, this configuration is applied and the package gets installed. Have you tried this?

Using this way helps to keep this package tied to the container ddev uses. While adding it to a running container (as you did) is not explicitly wrong, this package will be removed again if you change the PHP version or upgrade ddev. Through using the configuration, you can ensure that this package is installed again if the container images change.