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

前端 未结 11 1047
Happy的楠姐
Happy的楠姐 2021-01-30 02:21

I want to build my PHP-FPM image with php-redis extension based on the official PHP Docker image, for example, using this Dockerfile: php:5.6-fpm.

The docs

11条回答
  •  终归单人心
    2021-01-30 02:42

    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.

    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
    

提交回复
热议问题