Reputation: 79
I have setup the new Docker container with image "FROM php:7.3-apache-stretch" and trying to install 'Opcache' into it but fails.
System: Linux
PHP Version: 7.3.11
Apache Version: Apache/2.4.25 (Debian)
DockerFile
FROM php:7.3-apache-stretch
ARG DEBIAN_FRONTEND=noninteractive
# Update
RUN apt-get -y update --fix-missing && \
apt-get upgrade -y && \
apt-get --no-install-recommends install -y apt-utils && \
rm -rf /var/lib/apt/lists/*
# Install useful tools and install important libaries
RUN apt-get -y update && \
apt-get -y --no-install-recommends install nano vim wget dialog libsqlite3-dev libsqlite3-0 && \
apt-get -y --no-install-recommends install mysql-client zlib1g-dev libzip-dev libicu-dev && \
apt-get -y --no-install-recommends install --fix-missing apt-file apt-utils build-essential git curl && \
apt-get -y --no-install-recommends install --fix-missing libcurl3 libcurl3-dev zip openssl && \
rm -rf /var/lib/apt/lists/* && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Other PHP7 Extensions
RUN docker-php-ext-install pdo_mysql && \
docker-php-ext-install pdo_sqlite && \
docker-php-ext-install mysqli && \
docker-php-ext-install curl && \
docker-php-ext-install tokenizer && \
docker-php-ext-install json && \
docker-php-ext-install zip && \
docker-php-ext-install -j$(nproc) intl && \
docker-php-ext-install mbstring && \
docker-php-ext-install gettext
# Install Freetype
RUN apt-get -y update && \
apt-get --no-install-recommends install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install -j$(nproc) gd
# Enable apache modules
RUN a2enmod rewrite headers
# Cleanup
RUN rm -rf /usr/src/*
List of Extensions available in system:
root@24dd119aaa1f:/usr/local/lib/php/extensions/no-debug-non-zts-20180731# ls -l
total 4968
-rwxr-xr-x 1 root staff 111872 Nov 11 16:22 curl.so
-rwxr-xr-x 1 root staff 453536 Nov 11 16:24 gd.so
-rwxr-xr-x 1 root staff 18616 Nov 11 16:23 gettext.so
-rwxr-xr-x 1 root staff 1667064 Nov 11 16:22 intl.so
-rwxr-xr-x 1 root staff 50216 Nov 11 16:22 json.so
-rwxr-xr-x 1 root staff 1795120 Nov 11 16:23 mbstring.so
-rwxr-xr-x 1 root staff 170520 Nov 11 16:22 mysqli.so
-rwxr-xr-x 1 root staff 531752 Oct 25 02:54 opcache.so
-rwxr-xr-x 1 root staff 37800 Nov 11 16:21 pdo_mysql.so
-rwxr-xr-x 1 root staff 40176 Nov 11 16:21 pdo_sqlite.so
-rwxr-xr-x 1 root staff 80296 Oct 25 02:54 sodium.so
-rwxr-xr-x 1 root staff 27224 Nov 11 16:22 tokenizer.so
-rwxr-xr-x 1 root staff 78976 Nov 11 16:22 zip.so
root@24dd119aaa1f:/usr/local/etc/php/conf.d# ls -l
total 28
-rw-r--r-- 1 root staff 16 Nov 11 16:24 docker-php-ext-gd.ini
-rw-r--r-- 1 root staff 21 Nov 11 16:23 docker-php-ext-gettext.ini
-rw-r--r-- 1 root staff 18 Nov 11 16:22 docker-php-ext-intl.ini
-rw-r--r-- 1 root staff 20 Nov 11 16:22 docker-php-ext-mysqli.ini
-rw-r--r-- 1 root staff 23 Nov 11 16:21 docker-php-ext-pdo_mysql.ini
-rw-r--r-- 1 root staff 20 Oct 25 02:54 docker-php-ext-sodium.ini
-rw-r--r-- 1 root staff 17 Nov 11 16:22 docker-php-ext-zip.ini
php.ini
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=1
; The OPcache shared memory storage size.
opcache.memory_consumption=128
; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8
; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 1000000 are allowed.
opcache.max_accelerated_files=10000
When Tried to Install Opcache:
root@24dd119aaa1f:/usr/local/lib/php/extensions/no-debug-non-zts-20180731# docker-php-ext-install opcache
tar (child): /usr/src/php.tar.xz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Ensured xz-utils is installed:
root@24dd119aaa1f:/usr/local/lib/php/extensions/no-debug-non-zts-20180731# apt-get install xz-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
xz-utils is already the newest version (5.2.2-1.2+b1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Not sure where its going wrong ? btw, I can't re-create a docker image as that would hamper the existing projects.
Upvotes: 2
Views: 4231
Reputation: 6506
Using this Dockerfile:
FROM php:7.3-apache-stretch
RUN docker-php-ext-install -j$(nproc) opcache
this way:
docker build --tag stackoverflow .
gives cli output:
----------------------------------------------------------------------
Libraries have been installed in:
/usr/src/php/ext/opcache/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
and the command:
docker run --rm -it --entrypoint="" stackoverflow /bin/sh
and next into CLI
php -m
gives info:
[Zend Modules]
Zend OPcache
Happy coding :)
Upvotes: 1