跳转至

如何为 Docker容器添加 php-imap扩展模块?


2018-05-29 by dongnan

问题描述

php:5.6-fpm 容器,安装 imap模块提示 configure: error: utf8_mime2text() has ...

错误信息

docker-php-ext-install imap

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

环境

Debian 8.9 On php:5.6-fpm
Docker 17.05.0-ce

解决方法

依赖关系

imap 依赖 libc-client-devlibkrb5-dev 软件包,需要提前安装它们。

apt-get update && 
    apt-get install -y libc-client-dev libkrb5-dev && 
    rm -r /var/lib/apt/lists/*

安装扩展

依赖软件安装完成后,再次安装 imap 扩展。

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

验证

安装 imap 扩展成功。

php -m | grep imap

imap

Dockerfile

基于 php:5.6-fpm 官方镜像,增加 NginxPHP扩展自定义镜像。

cat 5.6/Dockerfile 

# php-fpm:5.6

FROM php:5.6-fpm
MAINTAINER dongnan

# apt
COPY conf/sources.list /etc/apt/sources.list
RUN apt-get update && apt-get install -y \
    supervisor cron nginx \
    libmagickwand-dev bzip2 libmemcached-dev \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
    libpng-dev \
    && apt-get clean && rm -r /var/lib/apt/lists/*

# pecl
RUN docker-php-ext-install bcmath dba exif pdo_mysql bz2 zip mysql mysqli
# gd
RUN docker-php-ext-install -j$(nproc) iconv mcrypt \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd
# imagick
RUN pecl install imagick && docker-php-ext-enable imagick
# memcached
RUN pecl install memcached-2.2.0 && docker-php-ext-enable memcached
# redis
RUN pecl install redis-4.3.0 && docker-php-ext-enable redis
# soap
RUN docker-php-ext-install soap && docker-php-ext-enable soap

# php
COPY conf/php.ini /usr/local/etc/php/php.ini
COPY conf/php-www.conf /usr/local/etc/php-fpm.d/www.conf
COPY conf/php-docker.conf /usr/local/etc/php-fpm.d/docker.conf

# nginx
COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY conf/default.conf /etc/nginx/conf.d/default.conf

# supervisor
RUN mkdir -p /var/log/supervisor \
    &&  mkdir -p /var/log/php \
    && ln -sf /dev/stderr /var/log/nginx/error.log 
COPY conf/supervisord.conf /etc/supervisor/supervisord.conf

# env
ENV TZ=Asia/Shanghai
ENV LANG=en_US.UTF-8

#
EXPOSE 80

#
CMD ["/usr/bin/supervisord","-c","/etc/supervisor/supervisord.conf"]

参考

自定义一个PHP 镜像 Dockerfile

回到页面顶部