php:8.1 Dockerfile

以下为测试安装成功版本,目前本人只能安装php:8.1.19以下版本,以上目前测试一直报秘钥问题,无法安装成功,暂时解决不了。
另外使用php:8.1.19-fpm会有软件版本过高问题,本人目前通过降版处理,不知大神有没什么其他更好的安装方式,欢迎留言指导。

# 参考文档https://segmentfault.com/a/1190000040911923
FROM php:8.1.19-fpm

# 设置时间
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo 'Asia/Shanghai' > /etc/timezone

# 使用阿里云镜像源
RUN echo "deb http://mirrors.aliyun.com/debian/ buster main" > /etc/apt/sources.list \
    && echo "deb-src http://mirrors.aliyun.com/debian/ buster main" >> /etc/apt/sources.list \
    && echo "deb http://mirrors.aliyun.com/debian/ buster-updates main" >> /etc/apt/sources.list \
    && echo "deb-src http://mirrors.aliyun.com/debian/ buster-updates main" >> /etc/apt/sources.list \
    && echo "deb http://mirrors.aliyun.com/debian-security/ buster/updates main" >> /etc/apt/sources.list \
    && echo "deb-src http://mirrors.aliyun.com/debian-security/ buster/updates main" >> /etc/apt/sources.list


# 依赖软件版本过高,先降级
RUN apt-get update && apt-get install -y --allow-downgrades \
    libgmp10=2:6.1.2+dfsg-4+deb10u1 \
    libnghttp2-14=1.36.0-2+deb10u2 \
    libpcre3=2:8.39-12 \
    libsasl2-2=2.1.27+dfsg-1+deb10u2 \
    libssl1.1=1.1.1n-0+deb10u6 \
    zlib1g=1:1.2.11.dfsg-1+deb10u2
RUN apt-get autoclean && apt-get clean

# 安装需要工具和依赖
RUN apt-get update && apt-get install -y \
    vim \
    curl \
    wget \
    git \
    zip \
    libz-dev \
    libssl-dev \
    libnghttp2-dev \
    libpcre3-dev \
    libmemcached-dev \
    zlib1g-dev \
    libgmp-dev

# 清理不需要的软件包和文件
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Composer安装
RUN curl -sS https://getcomposer.org/installer | php \
    && mv composer.phar /usr/local/bin/composer \
    && composer self-update --clean-backups

# 自带扩展安装
RUN docker-php-ext-install bcmath pdo_mysql sockets gmp \
    && docker-php-ext-enable opcache

# Redis扩展安装
RUN pecl install redis-beta && docker-php-ext-enable redis

# swoole 扩展下载 pecl本地安装 开启扩展
RUN wget http://pecl.php.net/get/swoole-4.8.12.tgz -O /tmp/swoole.tgz \
    && pecl install /tmp/swoole.tgz \
    && rm -rf /tmp/swoole.tgz \
    && docker-php-ext-enable swoole

# 复制配置文件
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!