Issue
I'm trying to test some PHP code on PHP 5.3 with the GMP extension installed. Here's my Dockerfile:
FROM php:5.3
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 AA8E81B4331F7F50 9D6D8F6BC857C906 \
&& apt-get update \
&& apt-get -y install libgmp-dev \
&& docker-php-ext-install gmp
When I try to build that I get an error about how docker-php-ext-install
doesn't exist.
Here's my second attempt:
FROM php:5.3
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 AA8E81B4331F7F50 9D6D8F6BC857C906 \
&& apt-get update \
&& apt-get -y install php5-gmp
That builds without issue but apparently that doesn't actually result in PHP having the GMP extension. I thought maybe I'd need to add extension=gmp.so
to the php.ini file but it's not immediately clear to me where that file lives. php -i | grep ini
returns, among other things, this:
Configuration File (php.ini) Path => /usr/local/lib
But there's no php.ini file in that directory. I tried to create one but still no luck.
Per chance there's a PHP 5.3 image floating around that already has the GMP extension installed?
Solution
I was able to do it thusly:
FROM php:5.3
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 AA8E81B4331F7F50 9D6D8F6BC857C906 \
&& apt-get update \
&& apt-get install -y libgmp-dev wget \
&& ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \
&& cd /tmp \
&& wget --no-check-certificate https://museum.php.net/php5/php-5.3.29.tar.xz \
&& tar xvf php-5.3.29.tar.xz \
&& cd php-5.3.29/ext/gmp \
&& phpize \
&& ./configure \
&& make \
&& make install \
&& echo extension=gmp.so > /usr/local/lib/php.ini
Answered By - neubert