How to install extension for php via docker-php-ext-install?

后端 未结 5 832
再見小時候
再見小時候 2020-12-28 13:40

In order to resolve an issue, I am now trying install the mysql pdo via

docker-php-ext-install

as pointed out in the README of the php imag

5条回答
  •  暖寄归人
    2020-12-28 14:04

    I had the same problem a while ago. I started a container and typed the ext-install command into this container. Once I found all the dependencies, I wrote them into the Dockerfile.

    Example:

    RUN apt-get update && apt-get install -y \
    libmcrypt-dev \
    && docker-php-ext-install -j$(nproc) mcrypt
    

    There is a dependency that libmcrypt-dev needed before you can run docker-php-ext-install mcrypt

    I've checked my older Dockerfiles and found something which might help you

    FROM php:5.6-apache
    
    RUN apt-get update && apt-get install -y \
            libfreetype6-dev \
            libjpeg62-turbo-dev \
            libmcrypt-dev \
            libpng12-dev \
        libicu-dev \
         libxml2-dev \
        vim \
            wget \
            unzip \
            git \
        && docker-php-ext-install -j$(nproc) iconv intl xml soap mcrypt opcache pdo pdo_mysql mysqli mbstring \
        && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
        && docker-php-ext-install -j$(nproc) gd
    
    RUN a2enmod rewrite && mkdir /composer-setup && wget https://getcomposer.org/installer -P /composer-setup && php /composer-setup/installer --install-dir=/usr/bin && rm -Rf /composer-setup && curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony && chmod a+x /usr/local/bin/symfony
    # Create symlink for default conf
    RUN ln -s /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/000-default.conf && mkdir /composer-setup && wget https://getcomposer.org/installer -P /composer-setup && php /composer-setup/installer --install-dir=/usr/bin && rm -Rf /composer-setup && curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony && chmod a+x /usr/local/bin/symfony
    

提交回复
热议问题