安裝擴展庫的通常命令
docker-php-ext-install 擴展庫名
安裝gd庫需要特殊照顧,步驟如下
//進入PHP容器
//更新軟件源
apt update
//安裝各種庫
apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev
//解壓源碼
docker-php-source extract
//進入gd源碼文件夾
cd /usr/src/php/ext/gd
//准備編譯
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
//查看是否成功安裝gd擴展
php -m | grep gd
//重啟容器