Docker PHP5.6调用未定义的函数bindtextdomain()

问题:</ strong> </ p>

我有一个Docker 使用nginx服务和PHP服务。
当我尝试打开我的开发项目的页面时,我遇到了这个错误:</ p>


致命错误:调用undefined 函数bindtextdomain()在第16行的/usr/share/nginx/html/some_project/some_path/Bootstrap.php中</ p>
</ blockquote>

我看到这是一个缺失的问题 依赖: php-gettext </ code>。</ p>

我的配置:</ strong> </ p>

在我的Dockerfile中,我 尝试安装它:</ p>

  FROM php:5.6.30-fpm 
MAINTAINER DarckCrystale“xxx@xxx.xx

#这里我尝试安装php- gettext extension
#但它不起作用
RUN apt-get update&amp;&amp; apt-get install -y php-gettext gettext

#设置PHP配置
ADD php.ini /usr/local/etc/php/conf.d/php.ini

</ pre> \ n

在我的php.ini中,我加载它:</ p>

  extension = gettext.so 
</ code> </ pre>

其他信息:</ strong> </ p>

当我在容器中运行时</ p>

  php -i |  grep extension_dir 
</ code> </ pre>

我显示此消息:</ p>


PHP警告:PHP启动:无法加载 动态库'/usr/local/lib/php/extensions/no-debug-non-zts-20131226/gettext.so' - / usr / local / lib / php / extensions / no-debug-non-zts-20131226 / gettext.so:无法打开共享对象文件:第0行的“未知”中没有此类文件或目录</ p>
</ blockquote>

对我来说似乎是:</ strong> </ p>

我认为</ p>

  RUN apt-get update&amp;&amp;  apt-get install -y php-gettext gettext 
</ code> </ pre>

不安装 php-gettext </ code>扩展名。 我不知道为什么。 我认为这是一个PHP Dockerized特定问题。</ p>
</ div>

展开原文

原文

Problem:

I have a Docker compose with an nginx service and a PHP service. When I try to open a page of my dev project, I encounter this error:

Fatal error: Call to undefined function bindtextdomain() in /usr/share/nginx/html/some_project/some_path/Bootstrap.php on line 16

I saw that is a problem of a missing dependency: php-gettext.

My configuration:

In my Dockerfile, I try to install it:

FROM php:5.6.30-fpm
MAINTAINER DarckCrystale "xxx@xxx.xx"

# Here I try to install the php-gettext extension
# but it does not work
RUN apt-get update && apt-get install -y php-gettext gettext

# Setup PHP configuration
ADD php.ini /usr/local/etc/php/conf.d/php.ini

In my php.ini, I load it:

extension=gettext.so

Other information:

When I run in my container

php -i | grep extension_dir

I have this message displayed:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/gettext.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20131226/gettext.so: cannot open shared object file: No such file or directory in Unknown on line 0

What it seems to be to me:

I think

RUN apt-get update && apt-get install -y php-gettext gettext

does not install the php-gettext extension. I don't know why. I think this is a PHP Dockerized specific problem.

1个回答



因此,经过努力,我终于找到了如何在PHP容器中安装此扩展程序!</ p>

如何解决此问题?</ strong> </ p>

使用 docker-php-ext-install </ code>代替 apt-get install < / code>在Dockerfile中:</ p>

  FROM php:5.6.30-fpm 
MAINTAINER DarckCrystale“xxx@xxx.xx

#这里我安装了php- gettext扩展
#并且它有效! :D
RUN docker-php-ext-install gettext

#设置PHP配置
ADD php.ini /usr/local/etc/php/conf.d/php.ini

有什么问题?</ strong> </ p>

PHP容器有一种特定的方式来安装PHP扩展:</ p>


如何安装更多PHP扩展</ strong> </ p>

我们提供帮助脚本 docker-php-ext-configure </ code >, docker-php-ext-install </ code>和 docker-php-ext-enable </ code>,以便更轻松地安装PHP扩展。</ p>
</ blockquote> \ n

所以 php-gettext </ code>扩展安装似乎只能使用提供的脚本。</ p>
</ div>

展开原文

原文

So, after struggle, I finally found how to install this extension in the PHP container!

How to solve this problem?

Use docker-php-ext-install instead of apt-get install in the Dockerfile:

FROM php:5.6.30-fpm
MAINTAINER DarckCrystale "xxx@xxx.xx"

# Here I install the php-gettext extension
# and it works! :D
RUN docker-php-ext-install gettext

# Setup PHP configuration
ADD php.ini /usr/local/etc/php/conf.d/php.ini

What is the problem?

PHP container have a specific way to install PHP extensions:

How to install more PHP extensions

We provide the helper scripts docker-php-ext-configure, docker-php-ext-install, and docker-php-ext-enable to more easily install PHP extensions.

So php-gettext extension installation seems to work only using provided scripts.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐