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"]
Without Docker I installed it with apt-get install php5-redis
. But how can I install it using the approach above?
docker-php-ext-enableThis command is used to start PHP extension of When we use pecl to install the PHP extension, the extension is not started by default. If you want to use this extension, you must configure it in the php. ini configuration file to use this PHP extension.
PHP Core ExtensionsIf an extension needs custom configure arguments, you can use the docker-php-ext-configure script like this example. There is no need to run docker-php-source manually in this case, since that is handled by the configure and install scripts.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With