2

I'm using docker for my web I have install php7.4-apache

FROM php:7.4.2-apache
COPY . /var/www/html
COPY ./docker/web/conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini

RUN a2enmod headers rewrite

RUN docker-php-ext-install mysqli pdo pdo_mysql exif

RUN rm /etc/apt/preferences.d/no-debian-php 

RUN apt-get update \
 && apt-get install --assume-yes --no-install-recommends --quiet \
    build-essential \
    libmagickwand-dev \
 && apt-get clean all

RUN pecl install imagick \
 && docker-php-ext-enable imagick

RUN apt-get update -y \
  && apt-get install -y \
    gpg-agent \
    curl \
    imagemagick \
    libgraphicsmagick1-dev \
    libmagickwand-dev \
    libcurl4-openssl-dev \
    libxml2-dev \
    libssl-dev \
    openssl \
    php-apcu \
    php-bcmath \
    php-calendar \
    php-cli \
    php-ctype \
    php-curl \
    php-common \
    php-dom \
    php-exif \
    php-fileinfo \
    php-fpm \
    php-gd \
    php-iconv \
    php-imagick \
    php-imap \
    php-intl \
    php-json \
    php-ldap \
    php-mbstring \
    php-mysql \
    php-opcache \
    php-phar \
    php-pear \
    php-posix \
    php-readline \
    php-shmop \
    php-simplexml \
    php-soap \
    php-sockets \
    php-sqlite3 \
    php-sysvmsg \
    php-sysvsem \
    php-sysvshm \
    php-tokenizer \
    php-xml \
    php-xmlreader \
    php-xmlwriter \
    php-xsl \
    php-zip \
    php-zend-code \
  && apt-get clean -y 

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN apt-get update -y && apt-get install -y libpng-dev libfreetype6-dev libjpeg-dev libbz2-dev libssl-dev

RUN apt-get update \
    && apt-get install -y \
        libicu-dev \
    && docker-php-ext-install -j$(nproc) \
        intl \
    && apt-get purge -y \
        libicu-dev

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

WORKDIR /var/www/html

#CREATE ADMINISTRATOR CACHE FOLDER + FOLDER (tmp and log)
RUN mkdir -p /var/www/html/tmp && chmod 777 -R /var/www/html/tmp \
&& chown root:www-data /var/www/html/* -R;

When I try to install an extension example php7.4-zip I get error :

E: Unable to locate package php7.4-zip 

but when I check php extensions I found all extensions are php7.3

root@086eb940b7e9:/var/www/html# php -v
PHP 7.4.2 (cli) (built: Feb  1 2020 19:39:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
root@086eb940b7e9:/var/www/html#

I did :

root@086eb940b7e9:/var/www/html# apt-cache search php | grep "^php7"

I get result :

php7.3 - server-side, HTML-embedded scripting language (metapackage)
php7.3-bcmath - Bcmath module for PHP
php7.3-bz2 - bzip2 module for PHP
php7.3-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.3-cli - command-line interpreter for the PHP scripting language
php7.3-common - documentation, examples and common module for PHP
php7.3-curl - CURL module for PHP
php7.3-dba - DBA module for PHP
php7.3-dev - Files for PHP7.3 module development
php7.3-enchant - Enchant module for PHP
php7.3-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.3-gd - GD module for PHP
php7.3-gmp - GMP module for PHP
php7.3-imap - IMAP module for PHP
php7.3-interbase - Interbase module for PHP
php7.3-intl - Internationalisation module for PHP
php7.3-json - JSON module for PHP
php7.3-ldap - LDAP module for PHP
php7.3-mbstring - MBSTRING module for PHP
php7.3-mysql - MySQL module for PHP
php7.3-odbc - ODBC module for PHP
php7.3-opcache - Zend OpCache module for PHP
php7.3-pgsql - PostgreSQL module for PHP
php7.3-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.3-pspell - pspell module for PHP
php7.3-readline - readline module for PHP
php7.3-recode - recode module for PHP
php7.3-snmp - SNMP module for PHP
php7.3-soap - SOAP module for PHP
php7.3-sqlite3 - SQLite3 module for PHP
php7.3-sybase - Sybase module for PHP
php7.3-tidy - tidy module for PHP
php7.3-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.3-xmlrpc - XMLRPC-EPI module for PHP
php7.3-xsl - XSL module for PHP (dummy)
php7.3-zip - Zip module for PHP
root@086eb940b7e9:/var/www/html#

apt list | grep php | grep zip

root@086eb940b7e9:/var/www/html# apt list | grep php | grep zip

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

php-pclzip/oldstable 2.8.2-4 all
php-zip/oldstable,now 2:7.3+69 all [installed]
php7.3-zip/oldstable,oldstable,now 7.3.31-1~deb10u1 amd64 [installed,automatic]
root@086eb940b7e9:/var/www/html# 
im-learning
  • 117
  • 2
  • 10
  • See if https://stackoverflow.com/questions/64500293/installing-php-zip-on-a-php7-4-fpm-image helps you. You may also have cache layers. If you can, run `docker system prune -af` to remove every layers and things in docker. – Saeed Apr 04 '22 at 05:22
  • @Saeed I did run docker image prune and docker system prune and also docker volume prune and docker network prune none of this work – im-learning Apr 04 '22 at 05:49
  • I tried in a VPS and it worked fine. How do you run that? I checked with `apt list | grep php | grep zip`, and `php -m` – Saeed Apr 04 '22 at 05:53
  • @Saeed I add the return of : `apt list | grep php | grep zip` – im-learning Apr 04 '22 at 06:09
  • So, it's installed and you can use that. Is your problem solved? – Saeed Apr 04 '22 at 06:11
  • @Saeed the problem that all extension are installed are php7.3 but I'm using php7.4.2 not php 7.3 – im-learning Apr 04 '22 at 06:16
  • When I run `apt-cache search php | grep "^php7"`, I get nothing. – Saeed Apr 04 '22 at 07:08
  • @Saeed : `root@1d0eaeac9eb6:/var/www/html# apt-cache search php | grep "^php7"` return `php7.3 - server-side, HTML-embedded scripting language (metapackage)` .... – im-learning Apr 04 '22 at 07:17
  • Please add your complete `Dockerfile`. – Saeed Apr 04 '22 at 07:23
  • @Saeed I did add my dockerfile to my question – im-learning Apr 04 '22 at 07:25
  • Result of `php -m` and `apt-cache search php | grep "^php7"` are different. You should install php extensions via `docker-php-ext-install` and then enable `docker-php-ext-enable`. – Saeed Apr 04 '22 at 07:49
  • @Saeed where to find docker-php-ext-install extension list ? Exemple I need gd and imagick and exif and zip – im-learning Apr 04 '22 at 08:06
  • 1
    Please see this answer: https://stackoverflow.com/questions/71665098/how-to-enable-php-extensions-when-using-the-image-php7-2-apache-with-docker-com/71667445#71667445. Like that, you may use combination of both `pecl install` and `docker-php-ext-install`. If you run `docker-php-ext-install`, you'll see default list. But you should do different for some of required extensions – Saeed Apr 04 '22 at 08:12

0 Answers0