Installing GMP extention on PHP 7.4 FPM Aplpine (Docker)

Viewed 5971

I'm having troubble installing the gmp extension on my docker image. My docker file looks like:

FROM php:7.4-fpm-alpine 

RUN docker-php-ext-install pdo pdo_mysql gmp

When I run this docker file I get the error:

configure: error: GNU MP Library version 4.2 or greater required.
ERROR: Service 'php' failed to build : The command '/bin/sh -c docker-php-ext-install pdo pdo_mysql gmp' returned a non-zero code: 1

I've tried the solution on this stackoverflow post, however it did not work for me.

Any ideas on how I can resolve this?

2 Answers

Like the error says: configure: error: GNU MP Library version 4.2 or greater required.

You can install GNU MP (GMP for short) on Alpine Linux by including the following in your Dockerfile:

RUN apk add gmp-dev

(or RUN apt-get install gmp-dev for other debian distros)

I spent half an hour on this, so just to clarify for anyone that is looking for a solution: adding these lines to the Dockerfile for php7.4 worked:

RUN apt-get install -y libgmp-dev
RUN docker-php-ext-install gmp
Related