1. <small id='JKJh9'></small><noframes id='JKJh9'>

        <i id='JKJh9'><tr id='JKJh9'><dt id='JKJh9'><q id='JKJh9'><span id='JKJh9'><b id='JKJh9'><form id='JKJh9'><ins id='JKJh9'></ins><ul id='JKJh9'></ul><sub id='JKJh9'></sub></form><legend id='JKJh9'></legend><bdo id='JKJh9'><pre id='JKJh9'><center id='JKJh9'></center></pre></bdo></b><th id='JKJh9'></th></span></q></dt></tr></i><div id='JKJh9'><tfoot id='JKJh9'></tfoot><dl id='JKJh9'><fieldset id='JKJh9'></fieldset></dl></div>
        <legend id='JKJh9'><style id='JKJh9'><dir id='JKJh9'><q id='JKJh9'></q></dir></style></legend>
          <bdo id='JKJh9'></bdo><ul id='JKJh9'></ul>
      2. <tfoot id='JKJh9'></tfoot>

      3. 使用官方 Alpine Docker 映像将 yaml 扩展添加到 php

        时间:2024-05-11
          <tbody id='xruXT'></tbody>
        <i id='xruXT'><tr id='xruXT'><dt id='xruXT'><q id='xruXT'><span id='xruXT'><b id='xruXT'><form id='xruXT'><ins id='xruXT'></ins><ul id='xruXT'></ul><sub id='xruXT'></sub></form><legend id='xruXT'></legend><bdo id='xruXT'><pre id='xruXT'><center id='xruXT'></center></pre></bdo></b><th id='xruXT'></th></span></q></dt></tr></i><div id='xruXT'><tfoot id='xruXT'></tfoot><dl id='xruXT'><fieldset id='xruXT'></fieldset></dl></div>

              <small id='xruXT'></small><noframes id='xruXT'>

              <tfoot id='xruXT'></tfoot><legend id='xruXT'><style id='xruXT'><dir id='xruXT'><q id='xruXT'></q></dir></style></legend>
                  <bdo id='xruXT'></bdo><ul id='xruXT'></ul>
                  本文介绍了使用官方 Alpine Docker 映像将 yaml 扩展添加到 php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用这个官方的 php Docker 镜像:https://github.com/docker-library/php/blob/76a1c5ca161f1ed6aafb2c2d26f83ec17360bc68/7.1/alpine/Dockerfile

                  I'm using this offical php Docker image: https://github.com/docker-library/php/blob/76a1c5ca161f1ed6aafb2c2d26f83ec17360bc68/7.1/alpine/Dockerfile

                  现在我需要添加对 yaml 扩展的支持,它不与 php 捆绑在一起.我看到我正在使用的基本图像使用 phpize.

                  Now I need to add support for yaml extension, that is not bundled with php. I see the base image I'm using uses phpize.

                  我正在尝试这种方法:

                  FROM php:7.1.5-alpine
                  
                  # Install and enable yaml extension support to php
                  RUN apk add --update yaml yaml-dev
                  RUN pecl channel-update pecl.php.net  
                  RUN pecl install yaml-2.0.0 && docker-php-ext-enable yaml
                  

                  但我得到这个错误:

                  running: phpize
                  Configuring for:
                  PHP Api Version:         20160303
                  Zend Module Api No:      20160303
                  Zend Extension Api No:   320160303
                  Cannot find autoconf. Please check your autoconf installation and the
                  $PHP_AUTOCONF environment variable. Then, rerun this script.
                  
                  ERROR: `phpize' failed
                  ERROR: Service 'php_env' failed to build: The command '/bin/sh -c pecl  install yaml-2.0.0 && docker-php-ext-enable yaml' returned a non-zero code: 1
                  

                  使用该图像并添加该支持的最惯用的 docker 方式是什么?

                  What is the most idiomatic docker way to use that image and add that support?

                  我应该使用它作为基础,还是可以添加参数以使想要的扩展可配置?

                  Should I use it as base, or is someway possible to add parameters in order to make wanted extension configurable?

                  推荐答案

                  Alpine 使用 apk 安装包.编译过程抱怨缺少 autoconf,它位于 Alpine 的 autoconf 包中.

                  Alpine uses apk to install packages. The compiling process is complaining about missing autoconf, which is found in Alpine's autoconf package.

                  我建议你运行这些命令:

                  I'd suggest you to run these commands:

                  RUN apk add --no-cache --virtual .build-deps 
                      g++ make autoconf yaml-dev
                  
                  RUN pecl channel-update pecl.php.net
                  RUN pecl install yaml-2.0.0 && docker-php-ext-enable yaml
                  
                  RUN apk del --purge .build-deps
                  

                  如果您需要安装其他非开发库,您可以在单独的 apk add 命令中安装它们.此过程将:

                  If you need to install other non-dev libraries, you can install them in a separate apk add command. This procedure will:

                  1. 安装构建依赖,使用 --no-cache 意味着您正在使用更新的索引而不是本地缓存(因此不需要 --update 或将 pkg 保存在缓存中).--virtual 表示您正在为所有那些以后可以删除的包创建一个虚拟引用(因为它们在编译过程之后无用)

                  1. install the build deps, using --no-cache means you're using an updated index and not cached locally (thus no need of --update or to save the pkg in the cache). --virtual means you're creating a virtual reference for all those packages that can later be deleted (because they're useless after the compiling process)

                  用 pecl 和 docker-php-ext-enable 做你的事情

                  do your stuff with pecl and docker-php-ext-enable

                  删除之前的构建deps

                  delete the previous build deps

                  如果您仍然遇到任何缺少的依赖项,您可以参考以下内容:https://pkgs.alpinelinux.org/包

                  If you still encounter any missing dependency, you can see as reference this: https://pkgs.alpinelinux.org/packages

                  这篇关于使用官方 Alpine Docker 映像将 yaml 扩展添加到 php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Docker-Compose 不会卷我的 php.ini 文件 下一篇:如何使用官方 PHP Docker 镜像方法安装 php-redis 扩展?

                  相关文章

                    <tfoot id='3LbCQ'></tfoot>
                  1. <legend id='3LbCQ'><style id='3LbCQ'><dir id='3LbCQ'><q id='3LbCQ'></q></dir></style></legend>
                      <bdo id='3LbCQ'></bdo><ul id='3LbCQ'></ul>

                      <small id='3LbCQ'></small><noframes id='3LbCQ'>

                      <i id='3LbCQ'><tr id='3LbCQ'><dt id='3LbCQ'><q id='3LbCQ'><span id='3LbCQ'><b id='3LbCQ'><form id='3LbCQ'><ins id='3LbCQ'></ins><ul id='3LbCQ'></ul><sub id='3LbCQ'></sub></form><legend id='3LbCQ'></legend><bdo id='3LbCQ'><pre id='3LbCQ'><center id='3LbCQ'></center></pre></bdo></b><th id='3LbCQ'></th></span></q></dt></tr></i><div id='3LbCQ'><tfoot id='3LbCQ'></tfoot><dl id='3LbCQ'><fieldset id='3LbCQ'></fieldset></dl></div>