基于CentOS 6.8 制作PHP5.6镜像

1 篇文章 0 订阅
1 篇文章 0 订阅

# 使用基于 CentOS 6.8 的官方镜像
FROM centos:6.8
#添加用户
RUN useradd -M -s /sbin/nologin www
#备份yum源
RUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

#设置yum源
COPY CentOS-Base.repo /etc/yum.repos.d/
# 定义环境变量
ENV PHP_VERSION 5.6.40

# 安装基本依赖
RUN yum -y update && \
    yum -y install epel-release && \
    yum -y install \
        gcc \
        gcc-c++ \
        make \
        zlib-devel \
        libxml2-devel \
        openssl-devel \
        curl-devel \
        libjpeg-turbo-devel \
        libpng-devel \
        freetype-devel \
        libmcrypt-devel \
        libxslt-devel \
        libtool \
        autoconf \
        wget \
        libicu \
        libicu-devel \
        libc-client-devel \
        readline-devel \
        unzip

# 下载并解压 PHP 源文件
ADD php/php-${PHP_VERSION}.tar.gz /tmp/php

# 编译安装 PHP
RUN cd /tmp/php/php-${PHP_VERSION} && \
    ./configure \
        --prefix=/usr/local/php \
        --with-config-file-path=/usr/local/php/etc \
        --enable-fpm \
        --with-fpm-user=www \
        --with-fpm-group=www \
        --enable-mbstring \
        --enable-mysqlnd \
        --with-mysqli=mysqlnd \
        --with-pdo-mysql=mysqlnd \
        --with-mysql=mysqlnd \
        --with-curl \
        --with-openssl \
        --with-zlib \
        --with-gd \
        --with-jpeg-dir \
        --with-png-dir \
        --with-freetype-dir \
        --with-mcrypt \
        --with-xmlrpc \
        --with-xsl \
        --with-pear \
        --with-pcre-regex \
        --with-gettext \
        --with-iconv \
        --with-mhash \
        --with-openssl \
        --with-readline \
        --without-sqlite3 \
        -without-pdo-sqlite \
        --enable-maintainer-zts \
        --with-kerberos \
        --enable-soap \
        --enable-pcntl \
        --enable-bcmath \
        --enable-mbregex \
        --enable-gd-native-ttf \
        --enable-intl \
        --enable-soap \
        --enable-session \
        --enable-pcntl \
        --enable-xml \
        --enable-inline-optimization \
        --enable-shared\
        --enable-zip && \
    make && make install


# 复制 PHP 配置文件
RUN cp /tmp/php/php-${PHP_VERSION}/php.ini-production /usr/local/php/etc/php.ini

# 配置 PHP-FPM
COPY php-fpm.conf /usr/local/php/etc/php-fpm.conf

# 清理安装过程中的临时文件
RUN rm -rf /tmp/php

#暴露端口
EXPOSE 9000

CMD ["/usr/local/php/sbin/php-fpm", "-F", "-y", "/usr/local/php/etc/php-fpm.conf"]

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值