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

前端 未结 11 1003
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:53

    Slightly revised version of starikovs and skyred answers for current version of the docker image. Tested on php:5-fpm-alpine

    # install phpredis extension
    ENV PHPREDIS_VERSION 2.2.8
    
    ADD https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz /tmp/redis.tar.gz
    RUN tar xzf /tmp/redis.tar.gz -C /tmp \
        && mkdir -p /usr/src/php/ext \
        && mv /tmp/phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
        && echo 'redis' >> /usr/src/php-available-exts \
        && docker-php-ext-install redis \
        && rm -rf /usr/src/php/ext/redis
    

提交回复
热议问题