PHP intl extension in Docker container

末鹿安然 提交于 2020-06-10 03:32:51

问题


I'm trying to load the intl PHP extension in my Docker container, but it doesn't seem to work.

Have already tried this https://github.com/docker-library/php/issues/57 but I still get the same error message:

configure: error: in `/usr/src/php/ext/intl':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details

My Docker file looks like this:

RUN apt-get -y update \
&& apt-get install -y libicu-dev\
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl

and it's loading from php:fpm

Have anyone gone through this and got to solve the problem? It's getting me nuts.


回答1:


It seems some requirements are missing. The snippet below worked for me:

ARG PHP_VERSION=5.6
FROM php:${PHP_VERSION}-fpm-jessie

apt-get install -y zlib1g-dev libicu-dev g++ \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl



回答2:


Your code worked perfectly for me once I added a space before the backslash terminating the second line of the run command:

RUN apt-get -y update \
&& apt-get install -y libicu-dev \ ### <-- Added space here
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl



回答3:


Unfortunately, some php extensions have dependencies to other programs. There is a project called docker-php-extension-installer that you can use to install PHP extensions. It will make sure that the required dependencies are present as well. See https://stackoverflow.com/a/56224300/413531 for an example how I actually integrate it in a Dockerfile.



来源:https://stackoverflow.com/questions/48674297/php-intl-extension-in-docker-container

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