在docker php 7.3上启用APCU CLI

时间:2019-02-22 16:32:43

标签: php docker apcu

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

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

当我尝试在此docker中运行测试时,由于apcu错误而导致测试失败。但是,在产品中,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信息时,结果是:

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

谢谢您的帮助。

致谢

1 个答案:

答案 0 :(得分:1)

抱歉,

我的错...

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

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