Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install the php memcached extension on Docker's PHP7 Alpine image?

The official php7 docker image has the following example:

FROM php:7.0-fpm
RUN apt-get update && apt-get install -y libmemcached-dev \
    && pecl install memcached \
    && docker-php-ext-enable memcached

I'm trying to use FROM php:7.0-fpm-alpine:

RUN apk add --update --no-cache libmemcached-dev
RUN      pecl install memcached && docker-php-ext-enable memcached

PECL gives this error:

pecl/memcached requires PHP (version >= 5.2.0, version <= 6.0.0, excluded versions: 6.0.0), installed version is 7.0.13

How can I install the memcached php extension on alpine?

like image 201
timetofly Avatar asked Nov 30 '16 17:11

timetofly


People also ask

What is PHP PECL memcache?

PHP License. Description. Memcached is a caching daemon designed especially for. dynamic web applications to decrease database load by. storing objects in memory.

Does Docker install PHP?

Docker is the industry standard for running containerised applications. By using a docker container you can create a consistent install of PHP that can be run locally or remotely without needing to install it on the underlying operating system.


1 Answers

Try it.

FROM php:7.2.10-fpm-alpine3.7


# Install PHP Extensions (igbinary & memcached)
RUN apk add --no-cache --update libmemcached-libs zlib
RUN set -xe && \
    cd /tmp/ && \
    apk add --no-cache --update --virtual .phpize-deps $PHPIZE_DEPS && \
    apk add --no-cache --update --virtual .memcached-deps zlib-dev libmemcached-dev cyrus-sasl-dev && \
# Install igbinary (memcached's deps)
    pecl install igbinary && \
# Install memcached
    ( \
        pecl install --nobuild memcached && \
        cd "$(pecl config-get temp_dir)/memcached" && \
        phpize && \
        ./configure --enable-memcached-igbinary && \
        make -j$(nproc) && \
        make install && \
        cd /tmp/ \
    ) && \
# Enable PHP extensions
    docker-php-ext-enable igbinary memcached && \
    rm -rf /tmp/* && \
    apk del .memcached-deps .phpize-deps
like image 76
SND-KNN Avatar answered Oct 28 '22 16:10

SND-KNN