简体   繁体   English

Dockerfile 安装 amqp 失败

[英]Dockerfile install amqp failed

I have some issues with my dockerfile... Here is the problem, I have a dockerfile based on this image -> FROM php:7.1.7-apache我的 dockerfile 有一些问题……这是问题所在,我有一个基于此图像的 dockerfile -> FROM php:7.1.7-apache

I want to install amqp extension for php.我想为 php 安装 amqp 扩展。 I was using pecl but since recently when i build my container i get an error.我正在使用 pecl,但自从最近在我构建容器时出现错误。

Here is the process i'm using in my dockerfile这是我在 dockerfile 中使用的过程

FROM php:7.1.7-apache

MAINTAINER T3ddy <xx@xxx.com>

RUN apt-get update

## TOOLS
RUN apt-get install -y \
    build-essential \
    curl \
    git \
    htop \
    ncdu \
    netcat \
    net-tools \
    telnet \
    unzip \
    vim \
    wget

## PHP AMQP
RUN apt-get install -y librabbitmq-dev libssl-dev
RUN pecl install amqp
RUN docker-php-ext-enable amqp

And when i get to the point of pecl install amqp...当我到达 pecl install amqp 的时候...

.......
/tmp/pear/temp/amqp/amqp.c: In function 'zm_startup_amqp':
/tmp/pear/temp/amqp/amqp.c:177:55: error: 'AMQP_SASL_METHOD_EXTERNAL' undeclared (first use in this function)
  REGISTER_LONG_CONSTANT("AMQP_SASL_METHOD_EXTERNAL",  AMQP_SASL_METHOD_EXTERNAL, CONST_CS | CONST_PERSISTENT);
                                                       ^
/usr/local/include/php/Zend/zend_constants.h:42:105: note: in definition of macro 'REGISTER_LONG_CONSTANT'
 #define REGISTER_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
                                                                                                         ^
/tmp/pear/temp/amqp/amqp.c:177:55: note: each undeclared identifier is reported only once for each function it appears in
  REGISTER_LONG_CONSTANT("AMQP_SASL_METHOD_EXTERNAL",  AMQP_SASL_METHOD_EXTERNAL, CONST_CS | CONST_PERSISTENT);
                                                       ^
/usr/local/include/php/Zend/zend_constants.h:42:105: note: in definition of macro 'REGISTER_LONG_CONSTANT'
 #define REGISTER_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
                                                                                                         ^
Makefile:194: recipe for target 'amqp.lo' failed
make: *** [amqp.lo] Error 1
ERROR: `make' failed
The command '/bin/sh -c pecl install amqp' returned a non-zero code: 1

And here is the error I got, I don't really understand why it failed, because since now it worked fine... Anyone got any idea.这是我得到的错误,我真的不明白为什么它失败了,因为现在它运行良好......任何人都知道。 Or a solution on how to install amqp without using pecl maybe ?或者关于如何在不使用 pecl 的情况下安装 amqp 的解决方案?

I published a script that lets you install the amqp PHP extension (and many others) with just these lines:我发布了一个脚本,让您只需使用以下几行即可安装 amqp PHP 扩展(以及许多其他扩展):

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
    install-php-extensions amqp

the scripts takes care of the PHP version, and install all the required APT (for Debian) or APK (for Alpine) packages.脚本负责处理 PHP 版本,并安装所有必需的 APT(适用于 Debian)或 APK(适用于 Alpine)软件包。

More details here: https://github.com/mlocati/docker-php-extension-installer更多细节在这里: https : //github.com/mlocati/docker-php-extension-installer

There was a new version of AMQP released on 2019-01-02 ( 1.9.4 ) which is not compatible right now as it seems. 2019-01-02 ( 1.9.4 ) 发布了一个新版本的 AMQP,目前似乎不兼容。 You can explicitly install 1.9.3 with pecl install amqp-1.9.3您可以使用pecl install amqp-1.9.3显式安装pecl install amqp-1.9.3

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

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