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

僤鯓⒐⒋嵵緔 提交于 2020-12-05 07:22:39

问题


I'm having problems trying to get imap working with my docker-compose.

Here is what my php dockerfile looks like.

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

But I keep getting the error

Call to undefined function imap_open()

I've been trying a lot of different ways of getting the imap to work, but nothing seems to be working for me. I need to keep using php7.2 so downgrading to php5 is not an option for me.

My ideal outcome is to keep the current php version of fpm and find a nice solution to get imap working with the current dockerfile.

Adding

Docker-php-ext-install imap 

inside the dockerfile does not seem to work and result with the following error:

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

回答1:


To use imap module with PHP in Docker you must configure extension like this

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

You can see an example of Dockerfile in one of my project




回答2:


Actual in 2020 for php 7.4 on 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



回答3:


Solved it by using

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

Found at https://stackoverflow.com/a/52314180/2311074



来源:https://stackoverflow.com/questions/49854767/docker-php7-2-fpm-cant-install-imap-module

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!