Search code examples
phpdockertimezonedb

install timezonedb in docker image


how to set extension=timezonedb.so in docker PHP image? install timezonedb in docker bash manual and add extension=timezonedb.so into php.ini but not worked for me.

install timezonedb in docker bash manual and add extension=timezonedb.so into php.ini but not worked for me.


Solution

  • https://serverfault.com/questions/1123233/why-doesnt-the-timezonedb-extension-have-the-latest-data

    Method 1.

    RUN docker-php-source extract \
        && pecl bundle -d /usr/src/php/ext timezonedb \
        && docker-php-ext-configure timezonedb \
        && docker-php-ext-install -j$(nproc) timezonedb \
        && docker-php-source delete
    

    Method 2.

    RUN mkdir -p /usr/local/src/pecl \
        && pecl bundle -d /usr/local/src/pecl timezonedb \
        && docker-php-ext-configure /usr/local/src/pecl/timezonedb \
        && docker-php-ext-install -j$(nproc) /usr/local/src/pecl/timezonedb \
        && rm -rf /usr/local/src/pecl
    

    Method 3.

    RUN apt-get -y install gcc make autoconf libc-dev pkg-config \
        && pecl install timezonedb \
        && bash -c "echo extension=timezonedb.so > /usr/local/etc/php/conf.d/docker-php-ext-timezonedb.ini"
    

    The 3 methods work properly. After building the docker container, I confirm that the extension is installed and loaded properly by checking the PHP information.