phpdockerdocker-composephp-extension

I'm searching for the activation location of my PHP extension in my PHP Docker container


When I check the activated extensions in my php Docker container, the output lists several PHP modules, such as Core, ctype, curl, and others.

the extensions appears to be deactivated In the php.ini file for example ;extension=curl, and when I try to activate it (), I encounter the following error

PHP Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20210902/curl (/usr/local/lib/php/extensions/no-debug-non-zts-20210902/curl: cannot open shared object file: No such file or directory)

I'm just trying to figure out where this activation is happening.

am using php:8.1.25-apache-bullseye


Solution

  • I understand that you try to use "curl" functions inside php scripts

    You need to add "curl" into the docker-php-ext-install instruction. From your Dockerfile

    FROM php:8.1.25-apache-bullseye
    WORKDIR /var/www/t3coredev
    
    ## Install system dependencies
    RUN apt-get update \
        && apt-get install -y \
        libxml2-dev \
        libzip-dev \
        zlib1g-dev \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        libjpeg-dev \
        libltdl-dev \
        libicu-dev \
        libmemcached-dev \
        libssl-dev \
        libonig-dev \
        iputils-ping \
        vim \
        wget \
        curl \
        git \
        build-essential \
        libcurl4 \
        libcurl4-openssl-dev \
        && rm -rf /var/lib/apt/lists/*
    
    # Install Composer manually
    RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
    
    ## Install PHP extensions
    RUN docker-php-ext-configure gd \
        --with-freetype=/usr/include/ \
        --with-jpeg=/usr/include/ \
        && docker-php-ext-install \
        pdo \
        session \
        filter \
        mbstring \
        intl \
        fileinfo \
        gd \
        zip \
        xml \
        dom \
        curl \
        pdo_mysql
    
    ## install ImageMagick https://www.linuxcapable.com/how-to-install-imagemagick-on-debian-linux/
    #RUN git clone https://github.com/ImageMagick/ImageMagick.git /usr/local/src/ImageMagick \
    #    cd /usr/local/src/ImageMagick \
    #    ./configure \
    #    make \
    #    make install \
    #    sudo ldconfig /usr/local/lib
    
    RUN a2enmod alias \
        && a2enmod authz_core \
        && a2enmod deflate \
        && a2enmod expires \
        && a2enmod filter \
        && a2enmod headers \
        && a2enmod rewrite \
        && a2enmod setenvif
    

    Once done, you should be able to run

    docker build . -t myimagetag
    

    Then to test if curl is enabled

    docker run myimagetag php -r 'echo curl_exec(curl_init("https://dog.ceo/api/breeds/image/random"));'
    

    That test curl for the php CLI usage