导航

docker php-fpm中安装GD库

Posted on 2021-01-12 18:56  displaynick  阅读(570)  评论(3编辑  收藏  举报

环境:Centos7.5

首先进入容器:

docker exec -it myphp7 /bin/bash

先添加软件源(我在这里浪费了很长时间,先后使用163和aliyun的源都报各种错误,直到使用中科大的源才可以)  

echo "deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free" > /etc/apt/sources.list \
>     && echo "deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free" >> /etc/apt/sources.list \
>     && echo "deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free" >> /etc/apt/sources.list \
>     && echo "deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free" >> /etc/apt/sources.list

更新

apt-get update  

安装必要的支持库

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

解压并切换目录

docker-php-source extract

cd /usr/src/php/ext

开始安装

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

看到如下提示表示安装成功:

Libraries have been installed in:
/usr/src/php/ext/gd/modules  

重启容器

docker restart myphp7
docker ps

打开浏览器查看phpinfo(),查看GD模块是否已经安装成功。