How to install php-redis extension using the official PHP Docker image approach? How to install php-redis extension using the official PHP Docker image approach? docker docker

How to install php-redis extension using the official PHP Docker image approach?


Redis is not an extension that is included in “php-src”, therefore you cannot use docker-php-ext-install. Use PECL:

RUN pecl install -o -f redis \&&  rm -rf /tmp/pear \&&  docker-php-ext-enable redis


My opinion, the easiest way is:

RUN pecl install redis && docker-php-ext-enable redis

;)


I've found two ways to install php-redis extension for official php-fpm Docker image. Here they are:

The first way is to compile redis from sources and install.

RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/2.2.7.tar.gz \    && tar xfz /tmp/redis.tar.gz \    && rm -r /tmp/redis.tar.gz \    && mv phpredis-2.2.7 /usr/src/php/ext/redis \    && docker-php-ext-install redis

docker-php-ext-install script is included in php-fpm image and can compile extensions and install them.

The second way you can do it is with PECL.

As TimWolla answered, you can do it with PECL, but in my case, PECL isn't installed by default.

RUN pecl install -o -f redis \&&  rm -rf /tmp/pear \&&  echo "extension=redis.so" > /usr/local/etc/php/conf.d/redis.ini