docker-library / php

Docker Official Image packaging for PHP
https://php.net
MIT License
3.84k stars 2.01k forks source link

Php redis extension does not enable for web PHP. #1458

Closed Luke-SF closed 11 months ago

Luke-SF commented 1 year ago

docker-php-ext-enable redis

does not fully work. "new Redis()" works in php command line but not in actual Laravel project/web http call.

Web phpinfo() shows it doesn't load it:

Configuration File (php.ini) Path | /usr/local/etc/php
Loaded Configuration File | (none)
Scan this dir for additional .ini files | /usr/local/etc/php/conf.d
Additional .ini files parsed | /usr/local/etc/php/conf.d/docker-fpm.ini, /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini, /usr/local/etc/php/conf.d/docker-php-ext-exif.ini, /usr/local/etc/php/conf.d/docker-php-ext-gd.ini, /usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini, /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini, /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini

and even when I attempt to load it in docker file it doesn't work:

RUN cat /usr/local/etc/php/conf.d/docker-php-ext-redis.ini >> /usr/local/etc/php/conf.d/docker-fpm.ini

No Redis section in phpinfo() and no Redis class available for some reason.

LaurentGoderre commented 1 year ago

Transfering to the PHP repo

LaurentGoderre commented 1 year ago

This worked for me

RUN set -eux; \
    pecl install redis; \
    docker-php-ext-enable redis;