Php: Add redis to installable extensions

Created on 16 Jul 2016  路  5Comments  路  Source: docker-library/php

Related to #262, I often want to install the very popular Redis client for PHP. This isn't trivial on Alpine Linux. If you could please support it, it'd help greatly.

Most helpful comment

apk add --update --no-cache autoconf g++ make
adds extra 200Mb to the 179Mb alpine package so I prefere to install it from source

ENV REDIS_VERSION 4.0.2

RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$REDIS_VERSION.tar.gz \
    && tar xfz /tmp/redis.tar.gz \
    && rm -r /tmp/redis.tar.gz \
    && mkdir -p /usr/src/php/ext \
    && mv phpredis-* /usr/src/php/ext/redis

RUN docker-php-ext-install redis

(last command purges all runtime packages after installation)
inspired by #77

All 5 comments

Steps:

$ apk add --update --no-cache autoconf g++ make
$ pecl install redis
$ docker-php-ext-enable redis

Hi @wernight redis is not shipped within php source code so, you should just follow explained steps in https://github.com/docker-library/php/issues/262#issuecomment-233108680.

Could there be a place for people to include ways to install common extensions, or some docker-php-ext-install run a script that does the install?

See https://github.com/docker-library/php/issues/75#issuecomment-353673374, which describes how I determine what's necessary to install extensions (and really compiled software in general).

Given that redis is not a built-in extension (as noted above), there's nothing for us to do here. Installing redis from PECL _is_ the appropriate solution. :+1:

apk add --update --no-cache autoconf g++ make
adds extra 200Mb to the 179Mb alpine package so I prefere to install it from source

ENV REDIS_VERSION 4.0.2

RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$REDIS_VERSION.tar.gz \
    && tar xfz /tmp/redis.tar.gz \
    && rm -r /tmp/redis.tar.gz \
    && mkdir -p /usr/src/php/ext \
    && mv phpredis-* /usr/src/php/ext/redis

RUN docker-php-ext-install redis

(last command purges all runtime packages after installation)
inspired by #77

Was this page helpful?
0 / 5 - 0 ratings