dockerfile 之php7的memcache、memcached、redis、mongodb 扩展安装

docker技巧

----------------------------------------------------- php 7 -------------------------------------------------------------------------------
参考:https://stackoverflow.com/questions/31369867/how-to-install-php-redis-extension-using-the-official-php-docker-image-approach
Slightly revised version of starikovs and skyred answers for the current PHP 7 version of the docker image (tested on php:7.0.8-fpm-alpine and php:7.0.8-alpine).
Uses the newly released 3.0 version (June 2016) for PHP 7.

安装redis扩展

ENV PHPREDIS_VERSION 3.0.0
RUN mkdir -p /usr/src/php/ext/redis \
    && curl -L https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz | tar xvz -C /usr/src/php/ext/redis --strip 1 \
    && echo 'redis' >> /usr/src/php-available-exts \
    && docker-php-ext-install redis
--------------------------------------------------------- php 7 -------------------------------------------------------------------
参考:https://stackoverflow.com/questions/40894385/how-can-i-install-the-php-memcached-extension-on-dockers-php7-alpine-image
安装memcached扩展:
ENV MEMCACHED_DEPS zlib-dev libmemcached-dev cyrus-sasl-dev
RUN apk add --no-cache --update libmemcached-libs zlib
RUN set -xe \
    && apk add --no-cache --update --virtual .phpize-deps $PHPIZE_DEPS \
    && apk add --no-cache --update --virtual .memcached-deps $MEMCACHED_DEPS \
    && pecl install memcached \
    && echo "extension=memcached.so" > /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini \
    && rm -rf /usr/share/php7 \
    && rm -rf /tmp/* \
    && apk del .memcached-deps .phpize-deps
---------------------------------------------------------------php 7----------------------------------------------------------------
安装memcache扩展:
RUN set -x \
    && cd /tmp \
    && curl -sSL -o php7.zip https://github.com/websupport-sk/pecl-memcache/archive/php7.zip \
    && unzip php7 \
    && cd pecl-memcache-php7 \
    && /usr/local/bin/phpize \
    apk add autoconf
    apk add --no-cache musl-dev
    && ./configure --with-php-config=/usr/local/bin/php-config \
    apk add make
    && make \
    && make install \
    && echo "extension=memcache.so" > /usr/local/etc/php/conf.d/docker-php-ext-memcache.ini \
    && rm -rf /tmp/pecl-memcache-php7 php7.zip
 -------------------------------------------------------- php7 -----------------------------------------------------------------------
安装 mongodb 扩展:
apk add --no-cache --virtual .build-deps pcre-dev
pecl install mongodb
echo "extension=mongodb.so" > /usr/local/etc/php/conf.d/docker-php-ext-mongodb.ini
------------------------------------------------------------------------------------