DOCKER 构建NGINX+PHP+MYSQL独立的容器

上面文章有介绍过docker里面安装php的扩展,但是在安装GD的时候,报错了,提示没有基础库

configure: error: png.h not found.

解决方法

先安装依赖库

apt update
apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev

再安装扩展如果直接按这种方式安装GD扩展,会缺少jpeg库,所以要先配置扩展,配置完jpeg库之后再安装GD,如果没有jpeg库支持,会报错Call to undefined function imagecreatefromjpeg()

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

如果是较高的php版本,比如php7.4

docker-php-ext-configure gd  --with-freetype --with-jpeg --with-webp --enable-gd
docker-php-ext-install gd

较高的版本里面参数有改变–with-webp-dir这些参数都不存在了

重启容器