docker php7.2-fpm无法安装imap模块

docker php7.2-fpm can't install imap module

我在尝试让 imap 与我的 docker-compose 一起工作时遇到问题。

这是我的 php docker 文件的样子。

FROM php:7.2-fpm

RUN apt-get update && \
  apt-get install -y \
    curl \
    libmcrypt-dev \
    unzip \
    git 

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install- 
dir=/usr/local/bin --filename=composer
RUN composer --version

# Set timezone to UTC
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/UTC /etc/localtime
RUN "date"

RUN apt-get -y install libmagickwand-dev --no-install-recommends \
    && pecl install imagick \
    && docker-php-ext-enable imagick \
    && rm -r /var/lib/apt/lists/*

RUN /usr/local/bin/docker-php-ext-install pdo pdo_mysql

ADD ./scripts/entry.sh /root/init.sh

WORKDIR /var/www/insight

但我一直收到错误

Call to undefined function imap_open()

我一直在尝试许多不同的方法来让 imap 工作,但似乎没有任何一种对我有用。我需要继续使用 php7.2,所以降级到 php5 对我来说不是一个选择。

我理想的结果是保留当前 php 版本的 fpm 并找到一个很好的解决方案让 imap 使用当前 docker 文件。

添加

Docker-php-ext-install imap 

在 docker 文件中似乎不起作用并导致以下错误:

configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

要在 Docker 中将 imap 模块与 PHP 一起使用,您必须像这样配置扩展

docker-php-ext-configure imap --with-kerberos --with-imap-ssl

您可以在我的 project

之一中查看 Docker 文件的示例

2020 年 PHP 7.4 和 PHP 8 在 Linux Alpine

上的实际值
RUN apk add imap-dev krb5-dev
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
        && docker-php-ext-install imap \
        && docker-php-ext-enable imap

使用

解决了
RUN apt update && apt install -y libc-client-dev libkrb5-dev && rm -r /var/lib/apt/

RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && docker-php-ext-install imap

发现于