【问题标题】:Docker & Laravel : configure: error: Package requirements (oniguruma) were not metDocker & Laravel:配置:错误:未满足包要求(oniguruma)
【发布时间】:2020-04-02 16:22:29
【问题描述】:

谁能帮我解决这个问题。

当我尝试从 dockerfile 为 laravel 应用程序创建 docker 映像时,我收到此错误:

正在检查 oniguruma...不 配置:错误:不满足包要求(oniguruma):

No package 'oniguruma' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

命令'/bin/sh -c docker-php-ext-install pdo mbstring'返回一个非零代码:1

这是我的 Dockerfile:

FROM php:7
RUN apt-get update -y && apt-get install -y openssl zip unzip git
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo mbstring
WORKDIR /app
COPY app /app # this copies all the app files to a folder called `app`
RUN composer install

CMD php artisan serve --host=0.0.0.0 --port=8000
EXPOSE 8000

以及构建 Dockerfile 的 docker 命令

sudo docker build -t test .

【问题讨论】:

    标签: php laravel docker dockerfile


    【解决方案1】:

    @kalatabe 说的是正确的。但如果您绝对想确保安装 mbstring,您也可以将 libonig-dev 添加到您的 apt-get install

    【讨论】:

    • 错误:无法选择包:#5 1.441 libonig-dev(没有这样的包):#5 1.441 需要:world[libonig-dev]
    • 我还必须将“libzip-dev”依赖项添加到 apt-get install
    【解决方案2】:

    只需从docker-php-ext-install 指令中删除mbstring

    该错误是由依赖问题引起的——mbstring 扩展需要oniguruma 库才能使多字节正则表达式函数工作。来自installation guide

    Oniguruma 是支持多字节字符的正则表达式函数所必需的。 Oniguruma 与 mbstring 捆绑在一起。从 PHP 5.4.0 开始,如果系统上已经安装了 Oniguruma,可以指定 --with-onig[=DIR] 以使用已安装的库。

    但是,在您使用的映像中,扩展程序已经安装和配置,因此您无需执行任何其他操作:

    $> docker run --rm -it php:7 php -r "var_dump(mb_ereg_match('^99.*', '123456'));"                                                                                      
    bool(false)
    
    $> docker run --rm -it php:7 php -r "var_dump(mb_ereg_match('^12.*', '123456'));"                                                                                      
    bool(true)
    

    【讨论】:

      【解决方案3】:

      对于phpbrew用户,

      您可以通过使用-mbstring 参数从安装命令中删除mbstring 变体来解决此错误。

      示例:

      phpbrew install php-7.4 +default -mbstring
      

      【讨论】:

        【解决方案4】:

        这在 Mac 上帮助了我

        • brew install oniguruma

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-09-21
          • 1970-01-01
          • 2019-09-15
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-11-10
          相关资源
          最近更新 更多