最新消息:XAMPP默认安装之后是很不安全的,我们只需要点击左方菜单的 "安全"选项,按照向导操作即可完成安全设置。

dockerfile编写自定义php镜像

XAMPP案例 中文小张 1400浏览 0评论

首先创建php目录

mkdir /opt/dockerfile/phpcd /opt/dockerfile/php

 

编写dockerfile文件

vim Dockerfile# 基础镜像FROM centos:7.6.1810# 镜像维护人MAINTAINER zhengshaoyongzsy@163.comRUN echo -e '/usr/local/lib64\n/usr/local/lib\n/usr/lib\n/usr/lib64'>> /etc/ld.so.conf \    && ldconfig -v    #&& cat /etc/ld.so.conf
# 更换yum源RUN yum -y install wgetRUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak \    && wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo \    && yum makecache
# 安装依赖RUN yum -y install epel-release libmcrypt-devel mhash-devel libxslt-devel \       libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \       zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \       ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \       krb5 krb5-devel libidn libidn-devel openssl openssl-devel libmcrypt-devel wget
RUN yum -y install gcc gcc-c++ perl
#RUN wget https://nih.at/libzip/libzip-1.2.0.tar.gz ADD libzip-1.2.0.tar.gz /usr/src/
WORKDIR /usr/srcRUN cd libzip-1.2.0 \    && ./configure \    && make -j8 \     && make install
RUN cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
RUN echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>/etc/ld.so.conf \    && ldconfig -v
# 安装phpRUN wget https://www.php.net/distributions/php-7.3.8.tar.gz \    && tar xvf php-7.3.8.tar.gz \    && cd php-7.3.8 \    && ./configure --prefix=/opt/php --exec-prefix=/opt/php \    --with-config-file-path=/opt/php/etc --enable-bcmath --enable-mbstring \    --with-gettext --enable-fpm --enable-shmop --enable-soap --enable-opcache \    --with-curl --disable-debug  --disable-rpath \    --enable-inline-optimization --with-bz2  --with-zlib --enable-sockets \    --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \    --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli \    --with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar --with-libdir=lib64 --with-openssl \    && make -j4 && make install
# 添加配置文件WORKDIR /usr/src/php-7.3.8 RUN cp php.ini-development /opt/php/etc/php.iniRUN cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.confRUN cp /opt/php/etc/php-fpm.d/www.conf.default /opt/php/etc/php-fpm.d/www.conf
# 修改配置文件为前台运行和允许所有IP访问RUN sed -i 's/;daemonize = yes/daemonize = no/g' /opt/php/etc/php-fpm.conf \    && sed -i 's/listen = 127.0.0.1:9000/listen = 0.0.0.0:9000/g' /opt/php/etc/php-fpm.d/www.confRUN cat /opt/php/etc/php-fpm.conf |grep daemonize# 允许在命令行下使用php命令RUN cp /opt/php/bin/php  /usr/local/bin/php
WORKDIR /opt/php/
# 设置对外端口EXPOSE 9000
# 启动phpCMD ["/opt/php/sbin/php-fpm"]

转载请注明:XAMPP中文组官网 » dockerfile编写自定义php镜像

您必须 登录 才能发表评论!