PHP 安装 gd 库 加载 freetype 的时候报错 有没有大神了解的

162 天前
 esons

FROM php:7.2-fpm-alpine

COPY custom.php.ini /usr/local/etc/php/conf.d/docker-php-custom.ini

RUN apk add autoconf g++ make util-linux-dev re2c icu-dev freetype-dev
openssl-dev pcre-dev libtool imagemagick imagemagick-dev postgresql-dev tzdata linux-headers git sudo libbsd libxml2-dev libzip-dev
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN docker-php-ext-configure gd --enable-gd --with-freetype RUN pecl install redis RUN docker-php-ext-enable redis

RUN docker-php-ext-install gd
&& docker-php-ext-install intl
&& docker-php-ext-install mysqli
&& docker-php-ext-install zip
&& docker-php-ext-install pdo_mysql
&& docker-php-ext-install pcntl
&& docker-php-ext-install pdo_pgsql
&& docker-php-ext-install soap
&& docker-php-ext-install bcmath
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
&& chmod +x /usr/local/bin/composer

报错信息: => ERROR [php72 4/8] RUN docker-php-ext-configure gd --enable-gd --with 14.3s

[php72 4/8] RUN docker-php-ext-configure gd --enable-gd --with-freetype: 1.148 fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/aarch64/APKINDEX.tar.gz 4.128 fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/aarch64/APKINDEX.tar.gz 7.641 (1/5) Installing dpkg-dev (1.20.0-r0) 9.347 (2/5) Installing dpkg (1.20.0-r0) 11.00 (3/5) Installing libmagic (5.38-r0) 12.50 (4/5) Installing file (5.38-r0) 13.90 (5/5) Installing .phpize-deps-configure (20231128.092650) 13.90 Executing busybox-1.31.1-r19.trigger 13.92 OK: 591 MiB in 158 packages 13.97 Configuring for: 13.97 PHP Api Version: 20170718 13.97 Zend Module Api No: 20170718 13.97 Zend Extension Api No: 320170718 14.27 configure: error: unrecognized options: --enable-gd, --with-freetype


failed to solve: process "/bin/sh -c docker-php-ext-configure gd --enable-gd --with-freetype" did not complete successfully: exit code: 1

604 次点击
所在节点    Docker
1 条回复
default996
162 天前
我自己是用这个的

```
FROM php:8.2-fpm-alpine

# 到 https://github.com/mlocati/docker-php-extension-installer
# 手动下载 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
# 然后放到 scripts 目录下
COPY scripts/* /usr/local/bin/


RUN install-php-extensions apcu bcmath calendar gd gettext ...其它扩展
```

搞定

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/996021

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX