docker环境中安装gd扩展

家住魔仙堡 提交于 2020-03-08 18:11:26
方案1

一般情况下可能会想到安装命令
docker-php-ext-install gd
但是很有可能出现错误
configure: error: png.h not found.
因为可能本身没有安装png等处理库

方案2
#更新安装依赖资源库
apt update
#安装基础库
apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev
#设置配置文件
docker-php-ext-configure gd --with-webp-dir=/usr/include/webp --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-freetype-dir=/usr/include/freetype2 
#安装扩展
docker-php-ext-install gd
#使扩展可用
docker-php-ext-enable gd

安装过程中如果出现了以下错误,可能是apt的源设置的不正确
在这里插入图片描述
可以在/etc/apt/source.list中设置中科大的源再尝试上面的操作
deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!