PHP Docker映像安装事件扩展失败

I'm trying to install the event extension in PHP Docker using pecl install event-2.5.3, however, it fails with the error:

Error relocating /usr/local/lib/php/extensions/no-debug-non-zts-20160303/event.so: php_sockets_le_socket: symbol not found in Unknown on line 0.

My Dockerfile:

FROM php:7.1.30-cli-alpine3.9
RUN apk --update add \
    autoconf \
    build-base \
    linux-headers \
    libevent-dev \
    openldap-dev \
    imagemagick-dev && \
    docker-php-ext-install pdo_mysql opcache sockets && \
    docker-php-ext-enable sockets && \
    pecl install event-2.5.3 && \
    docker-php-ext-enable event && \
    docker-php-ext-enable opcache \
    && rm -rf /var/cache/apk/*

This problem has puzzled me for a long time. Any suggestions?

drhs13583567608
drhs13583567608 我可以删除*imagemagick-dev&&\*行,但问题仍然存在
一年多之前 回复
dougang2749
dougang2749 我不是docker的专家,但你的列表只显示imagemagick-dev而不是imagemagick。我认为两者都是必需的。但这可能与您的问题无关。
一年多之前 回复

1个回答

I have solved the problem Going into your image, the ordering of these files determines which are loaded first

/usr/local/etc/php/conf.d # ls -al
total 28
drwxr-xr-x    2 root     root          4096 Jul  9 20:39 .
drwxr-xr-x    7 root     root          4096 Jul  9 20:01 ..
-rw-r--r--    1 root     root            19 Jul  9 18:39 docker-php-ext-event.ini
-rw-r--r--    1 root     root            82 Jul  9 18:39 docker-php-ext-opcache.ini
-rw-r--r--    1 root     root            23 Jul  9 18:38 docker-php-ext-pdo_mysql.ini
-rw-r--r--    1 root     root            21 Jul  9 18:38 docker-php-ext-sockets.ini
-rw-r--r--    1 root     root            20 Jun 28 02:48 docker-php-ext-sodium.ini

docker-php-ext-enable allows for a flag to change the .ini name, so doing a docker-php-ext-enable --ini-name zz-event.ini event has it load in last. so the correct Dockerfile should be

FROM php:7.1.30-cli-alpine3.9

# Packages
RUN apk add --no-cache \
    autoconf \
    build-base \
    linux-headers \
    libevent-dev \
    openldap-dev \
    imagemagick-dev

RUN docker-php-ext-install sockets pdo_mysql opcache

RUN docker-php-ext-enable opcache && \
    pecl install event-2.5.3 && \
    docker-php-ext-enable --ini-name zz-event.ini event


ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /tmp
ENV COMPOSER_VERSION 1.5.1


RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
 && composer --ansi --version --no-interaction

VOLUME /var/www
WORKDIR /var/www

CMD [ "php", "./public/server.php" ]
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐