Docker php-fpm 下载了GD扩展库依然不能生成验证码

使用phpinfo()确认GD扩展库中是否有 freetype 项

1、Freetype 下载

wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.10.tar.gz

# 如果使用 wget 的时候提示 bash: wget: command not found ,使用 apt 安装 wget
apt install -y wget

2、解压 freetype

tar zxvf freetype-2.4.10.tar.gz
cd freetype-2.4.10

3、编译 freetype 源文件

./configure --prefix=/usr/local/freetype # 指定将软件安装在 /usr/local/freetype 目录下

make && make install

4、重新配置 GD 扩展库并进行安装

docker-php-ext-configure gd --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include

docker-php-ext-install gd

5、重启 docker容器

docker restart <容器ID>