基于 Debian 9 stretch 制作 php 5.6.x 版本的 Dockerfile

很多时候还要考虑老版本的 php 运行环境,使用 docker 可以方便解决这个问题。

编写 Dockerfile

FROM php:5.6-fpm-stretch

RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak \
    && echo 'deb 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 \
    && apt-get update && apt-get upgrade -y

# Enable exts
RUN docker-php-ext-install -j$(nproc) bcmath exif gettext mysql mysqli pcntl pdo_mysql 

# GD
RUN apt-get update && apt-get install -y --no-install-recommends -y apt-utils zlib1g-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
    && rm -r /var/lib/apt/lists/* \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

# imagick
RUN export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS" \
    && apt-get update && apt-get install -y --no-install-recommends libmagickwand-dev \
    && rm -r /var/lib/apt/lists/* \
    && pecl install imagick-3.4.4 \
    && docker-php-ext-enable imagick

# Memcached
RUN apt-get update && apt-get install -y --no-install-recommends libmemcached-dev zlib1g-dev \
    && rm -r /var/lib/apt/lists/* \
    && pecl install memcached-2.2.0 \
    && docker-php-ext-enable memcached

# APCu
RUN pecl install apcu-4.0.11 && docker-php-ext-enable apcu

# redis
RUN pecl install redis-4.3.0 && docker-php-ext-enable redis

# opcache
RUN docker-php-ext-configure opcache --enable-opcache && docker-php-ext-install opcache

# libmcrypt
RUN apt-get update && apt-get install libmcrypt-dev -y && rm -r /var/lib/apt/lists/* \
    && docker-php-ext-install mcrypt

LABEL Author="Brian Zou"
LABEL Version="2020.06.22"
LABEL Description="PHP 5.6.x Version"

制作镜像

docker build -t php56-fpm:0622 .

运行 php 镜像

docker run --name php56-fpm -p 9000:9000 -v /data/www:/data/www -d php56-fpm:0622

你可能感兴趣的:(基于 Debian 9 stretch 制作 php 5.6.x 版本的 Dockerfile)