首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >“‘Opcache”未能在Docker中安装

“‘Opcache”未能在Docker中安装
EN

Stack Overflow用户
提问于 2019-11-12 13:42:19
回答 1查看 2.8K关注 0票数 2

我已经设置了一个新的Docker容器,它的映像为"FROM php:7.3-Apache-tending“,并试图将'Opcache‘安装到其中,但是失败了。

系统: Linux

PHP版本: 7.3.11

Apache版本: Apache/2.4.25 (Debian)

DockerFile

代码语言:javascript
运行
复制
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/*

系统中可用扩展的列表:

代码语言:javascript
运行
复制
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
代码语言:javascript
运行
复制
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

代码语言:javascript
运行
复制
; 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

尝试安装Opcache时的

代码语言:javascript
运行
复制
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

安装了确保xz-utils:

代码语言:javascript
运行
复制
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.

不知道哪里出了问题?顺便说一句,我不能重新创建一个码头形象,因为这会妨碍现有的项目。

EN

Stack Overflow用户

发布于 2019-11-18 22:25:00

使用此Dockerfile:

代码语言:javascript
运行
复制
FROM php:7.3-apache-stretch
RUN docker-php-ext-install -j$(nproc) opcache

这条路:

代码语言:javascript
运行
复制
docker build --tag stackoverflow .

给出cli输出:

代码语言:javascript
运行
复制
----------------------------------------------------------------------
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.
----------------------------------------------------------------------

而命令:

代码语言:javascript
运行
复制
docker run --rm -it --entrypoint="" stackoverflow /bin/sh

然后进入CLI

代码语言:javascript
运行
复制
php -m

提供信息:

代码语言:javascript
运行
复制
[Zend Modules]
Zend OPcache

快乐编码:)

票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58820032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档