Dockerfile PHP镜像制作

1 PHP镜像制作:

1.1 php-dockerfile

FROM centos:7
LABEL maintainer www.chenleilei.net
RUN yum install -y curl
RUN curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo && \
yum clean all
RUN yum remove oniguruma-devel -y
RUN yum remove oniguruma -y
RUN rpm -ivh https://www.chenleilei.net/soft/docker/oniguruma-6.7.0-1.el7.x86_64.rpm
RUN rpm -ivh https://www.chenleilei.net/soft/docker/oniguruma-devel-6.7.0-1.el7.x86_64.rpm
RUN yum install -y cmake pcre pcre-devel openssl openssl-devel gd-devel \
zlib-devel gcc gcc-c++ net-tools iproute telnet wget curl \
wget vim libxml2 libxml2-devel openssl openssl-devel libjpeg-turbo \
libjpeg-turbo-devel libpng-devel libpng freetype-devel freetype icu \
libicu-devel libicu libmcrypt libmcrypt-devel libxslt libxslt-devel  php-mysql libsqlite3x-devel && \
rm -rf /var/cache/yum/*
WORKDIR /
RUN useradd www -u 1200 -M -s /sbin/nologin && mkdir -p /usr/local/nginx/html && chown -R www.www /usr/local/nginx/html && chmod -R 755 /usr/local/nginx/html
RUN wget https://www.chenleilei.net/soft/php-7.4.3.tar.gz
RUN tar xf php-7.4.3.tar.gz
WORKDIR php-7.4.3
RUN ./configure --prefix=/usr/local/php-7.4.3 \
--with-config-file-path=/usr/local/php-7.4.3/etc \
--with-config-file-scan-dir=/usr/local/php-7.4.3/conf.d \
--enable-fpm --with-fpm-user=www \
--with-fpm-group=www \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-zlib \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--with-gettext \
--disable-fileinfo \
--enable-opcache \
--enable-intl \
--with-xsl
RUN make -j 4 && make install
RUN cp ./sapi/fpm/php-fpm.conf /usr/local/php-7.4.3/etc/php-fpm.conf && \
cp /php-7.4.3/php.ini-production /usr/local/php-7.4.3/etc/php.ini && \
cp /usr/local/php-7.4.3/etc/php-fpm.d/www.conf.default /usr/local/php-7.4.3/etc/php-fpm.d/www.conf && \
sed  -i  "s#127.0.0.1:9000#0.0.0.0:9000#g" /usr/local/php-7.4.3/etc/php-fpm.d/www.conf && \
sed -in '99idaemonize = yes' /usr/local/php-7.4.3/etc/php-fpm.conf && \
cp /php-7.4.3/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm && \
chmod a+x /etc/init.d/php-fpm
WORKDIR /
RUN rm -rf /php-7.4.3.tar.gz
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
CMD /usr/local/php-7.4.3/sbin/php-fpm -F
EXPOSE 9000

1.2 启动php

mkdir /www
docker run --name php-v001 -d -p 9000:9000 -v /www:/usr/local/nginx/html -v /var/log/nginx:/var/log/nginx --restart=always --privileged=true  php-v001

微信赞赏

支付宝赞赏

posted @ 2020-03-27 15:24  陈雷雷  阅读(2062)  评论(0编辑  收藏  举报