docker php-fpm中安裝GD庫
阿新 • • 發佈:2021-01-12
環境: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模組是否已經安裝成功。