码迷,mamicode.com
首页 > Web开发 > 详细

给docker里的php安装gd扩展

时间:2019-10-22 15:21:15      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:根据   libjpeg   doc   usr   php扩展   list   封装   开源   type   

docker官方镜像为安装php扩展封装了函数,为开发者提供了很大的便利,以下以Dockerfile的形式演示安装gd扩展的方法,安装gd扩展需要安装几个依赖包,安装依赖包使用系统命令,安装命令根据基础镜像的不同有所不同,以下演示两种使用较多的alpine和debian系统的Dockerfile,Dockerfile中同时包含更换国内开源镜像源的内容。

1、基础镜像 php:7.2-fpm-alpine

    Dockerfile如下:

FROM php:7.2-fpm-alpine

RUN sed -i ‘s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g‘ /etc/apk/repositories     && apk update     && apk add libpng-dev freetype-dev libjpeg-turbo-dev     && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/      && docker-php-ext-install -j$(nproc) gd

EXPOSE 9000
CMD ["php-fpm"]

 

2、基础镜像 php:7.2-fpm-stretch (debian 9) 

    Dockerfile如下:

FROM php:7.2-fpm-stretch

RUN echo "deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib" > /etc/apt/sources.list     && echo "deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib" >> /etc/apt/sources.list     && echo "deb http://mirrors.aliyun.com/debian-security stretch/updates main" >> /etc/apt/sources.list     && echo "deb-src http://mirrors.aliyun.com/debian-security stretch/updates main" >> /etc/apt/sources.list     && echo "deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list     && echo "deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list     && echo "deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list     && echo "deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list     && rm -f /etc/apt/sources.list.d/*     && apt-get update && apt-get install -y         libfreetype6-dev         libjpeg62-turbo-dev         libpng-dev     && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include     && docker-php-ext-install -j$(nproc) gd

EXPOSE 9000
CMD ["php-fpm"]

  

给docker里的php安装gd扩展

标签:根据   libjpeg   doc   usr   php扩展   list   封装   开源   type   

原文地址:https://www.cnblogs.com/liyuchuan/p/11718798.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!