简体   繁体   English

如何在 Alpine Linux 容器上为 PHP 安装 ZeroMQ?

[英]How to install ZeroMQ for PHP on an Alpine Linux container?

To be able to push notifications via WebSockets from PHP using Ratchet, I need to install ZeroMQ as stated in the documentation .为了能够使用 Ratchet 通过 WebSockets 从 PHP 推送通知,我需要按照文档中的说明安装 ZeroMQ。 However I didn't find any information about how to do it for Alpine Linux. Most of the time what we can find is with apt-get , for example here .但是我没有找到关于如何为 Alpine Linux 执行此操作的任何信息。大多数时候我们可以找到apt-get ,例如这里 Same about the Docker images (Dockerfile) available on Docker hub. Docker 图像 (Dockerfile) 在 Docker 中心可用。

Since the dependencies and their name seem different, how to do it with Alpine?由于依赖项和它们的名称似乎不同,如何使用 Alpine 来实现?

For those who face the same situation, I finally found how to do it:对于那些面临同样情况的人,我终于找到了方法:

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

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

In php:8.0-fpm-alpine , pecl install zmq-beta threw an error and failed to compile, so I used this command: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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM