douzhang3898 2017-04-11 08:58
浏览 158
已采纳

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

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条回答 默认 最新

  • dongzhimin2231 2017-04-11 08:58
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?