2

我正在尝试在我的 docker 容器上启用 apcu cli 以运行我的测试。这是我的 docker 文件,我使用:

  • 基本的php图像
  • 安装作曲家
  • 安装 xdebug
  • 安装更多 docker 库
  • 安装 apcu

当我尝试在此 docker 中运行测试时,由于 apcu 错误而失败。但是,在 prod 中,apcu 运行良好,因为它已启用,但测试需要启用 cli。

FROM php:7.3-cli

ARG APCU_VERSION=5.1.11

RUN apt-get update  && apt-get -y install git zip libzip-dev wget \
zlib1g-dev unzip libpq-dev git-core libmcrypt-dev vim libfcgi0ldbl gnupg \
libfreetype6-dev libjpeg62-turbo-dev libpng-dev libicu-dev

#INSTALL COMPOSER
RUN echo "memory_limit = -1" > /usr/local/etc/php/conf.d/memory_limit.ini
RUN curl -sS http://getcomposer.org/installer | php -- --filename=composer && chmod a+x composer  && mv composer /usr/local/bin/composer
RUN echo 'export PATH=~/.composer/vendor/bin:$PATH' >> ~/.bashrc
RUN composer global require hirak/prestissimo

#ENABLE DOCKER LIBS
RUN docker-php-ext-install zip pdo pdo_pgsql pgsql mbstring opcache -j$(nproc) gd
RUN docker-php-ext-configure intl && docker-php-ext-install intl
RUN docker-php-ext-configure opcache --enable-opcache
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

#INSTALL XDEBUG
RUN pecl install xdebug-2.7.0RC1 && docker-php-ext-enable xdebug
#XDEBUG

#INSTALL APCU
RUN pecl install apcu-${APCU_VERSION} && docker-php-ext-enable apcu
RUN echo "extension=apcu.so" > /usr/local/etc/php/php.ini
RUN echo "apc.enable_cli=1" > /usr/local/etc/php/php.ini
RUN echo "apc.enable=1" > /usr/local/etc/php/php.ini
#APCU

RUN php --ini
RUN php --info | grep apc

#MAKE tmp WRITABLE
RUN chmod 777 -R /tmp && chmod o+t -R /tmp

但最后当我打印 php info 时,结果是:

Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini,
apcu
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.mmap_file_mask => no value => no value
apc.preload_path => no value => no value
apc.serializer => php => php
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.slam_defense => On => On
apc.smart => 0 => 0
apc.ttl => 0 => 0
apc.use_request_time => On => On
apc.writable => /tmp => /tmp

谢谢您的帮助。

问候

4

2 回答 2

7

对不起,

我的错...

如果要将字符串附加到文件中,则必须>>在 echo 行上使用。

我希望这会对某人有所帮助,问候

于 2019-02-27T17:28:12.670 回答
0

只是

docker-php-ext-enable apc

或者

docker-php-ext-enable apcu
于 2021-10-25T04:47:05.170 回答