【问题标题】:How to install ZeroMQ for PHP on an Alpine Linux container?如何在 Alpine Linux 容器上安装 ZeroMQ for PHP?
【发布时间】:2022-05-03 20:17:43
【问题描述】:

为了能够使用 Ratchet 从 PHP 通过 WebSockets 推送通知,我需要按照documentation 中的说明安装 ZeroMQ。但是我没有找到有关如何为 Alpine Linux 执行此操作的任何信息。大多数时候我们可以找到apt-get,例如here。 Docker hub 上可用的 Docker 镜像(Dockerfile)也是如此。

由于依赖项和它们的名称看起来不同,那么如何使用 Alpine 呢?

【问题讨论】:

    标签: php docker zeromq alpine ratchet


    【解决方案1】:

    对于那些面临同样情况的人,我终于找到了方法:

    FROM php:7-cli-alpine
    RUN apk add autoconf gcc libzmq zeromq-dev zeromq coreutils build-base
    RUN pecl install zmq-beta \
       && docker-php-ext-enable zmq
    

    来源:https://smartango.com/2018/10/php-zmq-in-docker-and-checking-whether-the-c-compiler-works-no/

    【讨论】:

      【解决方案2】:

      在php:8.0-fpm-alpine,pecl install zmq-beta抛出错误,编译失败,所以我用了这个命令:

      FROM php:8.0-fpm-alpine
      ENV COMPOSER_ALLOW_SUPERUSER 1
      RUN set -eux && \
        apk add --update-cache --no-cache libzmq zeromq-dev zeromq && \
        apk add --update-cache --no-cache --virtual=.build-php-dependencies \
        autoconf gcc coreutils build-base git && \
        git clone https://github.com/mkoppanen/php-zmq.git && \
        cd php-zmq && \
        phpize && \
        ./configure && \
        make && \
        make install && \
        docker-php-ext-enable zmq && \
        apk del .build-php-dependencies
      

      参考:
      https://github.com/zeromq/php-zmq/issues/200#issuecomment-610161524

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-11
        • 2016-09-27
        • 1970-01-01
        • 2019-06-09
        • 2017-04-11
        • 1970-01-01
        相关资源
        最近更新 更多