如何使用官方 PHP Docker 映像方法安装 php-redis 扩展? [英] How to install php-redis extension using the official PHP Docker image approach?

查看:46
本文介绍了如何使用官方 PHP Docker 映像方法安装 php-redis 扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用基于 php-redis 扩展构建我的 PHP-FPM 映像="noreferrer">官方 PHP Docker 镜像,例如,使用这个 Dockerfile:php:5.6-fpm.

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 say that I can install extensions this way, installing dependencies for extensions manually:

FROM php:5.6-fpm
# Install modules (iconv, mcrypt and gd extensions)
RUN apt-get update && apt-get install -y 
        libfreetype6-dev 
        libjpeg62-turbo-dev 
        libmcrypt-dev 
        libpng12-dev 
    && docker-php-ext-install iconv mcrypt 
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
    && docker-php-ext-install gd
CMD ["php-fpm"]

在没有 Docker 的情况下,我使用 apt-get install php5-redis 安装了它.但是如何使用上述方法安装它?

Without Docker I installed it with apt-get install php5-redis. But how can I install it using the approach above?

推荐答案

Redis 不是php-src"中包含的扩展,因此不能使用 docker-php-ext-install.使用PECL:

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

在 alpine php 7.3.5 上我们可以使用:

On alpine php 7.3.5 we can use:

RUN apk add --no-cache pcre-dev $PHPIZE_DEPS 
        && pecl install redis 
        && docker-php-ext-enable redis.so

这篇关于如何使用官方 PHP Docker 映像方法安装 php-redis 扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆