• 给docker里的php安装gd扩展


    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"]
    

      

  • 相关阅读:
    BZOJ 3110 【ZJOI2013】 K大数查询
    【mysql的编程专题⑥】视图
    【mysql的编程专题⑤】自定义函数
    MySQL错误代码大全【转载】
    【mysql的编程专题④】存储过程
    【mysql的编程专题③】内置函数
    【mysql的编程专题】触发器
    【mysql的编程专题①】流程控制与其他语法
    多线程监听串口
    IMX6输出可控PWM
  • 原文地址:https://www.cnblogs.com/liyuchuan/p/11718798.html
Copyright © 2020-2023  润新知