Docker install PHP-7-fpm with Memcache extention ? fails with Cannot find config.m4
Here's how your Dockerfiles should look like:
PHP-FPM Dockerfile:
FROM php:7.0-fpm# ... RUN apt-get update && apt-get install -y \ libpq-dev \ libmemcached-dev \ curl# ... # Install Memcached for php 7RUN curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/php7.tar.gz" \ && mkdir -p /usr/src/php/ext/memcached \ && tar -C /usr/src/php/ext/memcached -zxvf /tmp/memcached.tar.gz --strip 1 \ && docker-php-ext-configure memcached \ && docker-php-ext-install memcached \ && rm /tmp/memcached.tar.gz# ... CMD ["php-fpm"]EXPOSE 9000
Memcached Dockerfile:
FROM memcached:latestCMD ["memcached"]EXPOSE 11211
This is taken from https://github.com/LaraDock/laradock
You need to run that command /usr/bin/phpize
in the right folder.
See this Dockerfile as an example
RUN wget https://github.com/phpredis/phpredis/archive/2.2.5.zip; unzip 2.2.5.zipWORKDIR /tmp/php-redis/phpredis-2.2.5RUN /usr/bin/phpize; ./configure; make; make install
In your case, you did clone the repo php-memcached
and make a cd
in it, but that does not change the working directory for the next Dockerfile RUN
directive.
Set that working directory before the RUN
directive:
WORKDIR /php-memcachedRUN /usr/bin/phpize
This work for me:
FROM php:7.1.1-fpmRUN apt-get updateRUN docker-php-ext-install mysqliRUN apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ libmcrypt-dev \ libpng12-dev \&& docker-php-ext-install -j$(nproc) iconv mcrypt \&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \&& docker-php-ext-install -j$(nproc) gdRUN apt-get install git -yRUN git --versionRUN apt-get install -y build-essential libmemcached-devRUN git clone https://github.com/php-memcached-dev/php-memcached.gitRUN cd php-memcached \&& git checkout php7 \&& phpize \&& ./configure --disable-memcached-sasl \&& make \&& make install