問題描述
我想使用基于 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 擴展?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!