gpt4 book ai didi

php - 在Docker中安装GD扩展

转载 作者:行者123 更新时间:2023-12-02 18:01:25 26 4
gpt4 key购买 nike

我是Docker的新手,正在尝试安装PHP 和GD 扩展。

这是我当前的Dockerfile:

FROM php:7.4-fpm-alpine

RUN docker-php-ext-install mysqli pdo pdo_mysql bcmath gd

通过 docker-compose build && docker-compose up -d运行docker时,出现很多错误,最后我得到以下消息:
configure: error: Package requirements (zlib) were not met:

Package 'zlib', required by 'virtual:world', not 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 ZLIB_CFLAGS
and ZLIB_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
ERROR: Service 'php' failed to build: The command '/bin/sh -c docker-php-ext-install mysqli pdo pdo_mysql bcmath gd' returned a non-zero code: 1

末尾没有“gd”的情况下,Docker容器可以正常运行。

可能是什么问题,我该如何解决?

最佳答案

您可以尝试在Dockerfile中添加以下设置:

FROM php:7.4-fpm
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd

官方 documentation。希望对您有帮助。

关于php - 在Docker中安装GD扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61228386/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com