PHP5.6 Dockerfile

个人学习笔记,谢绝转载!!!
原文:https://www.cnblogs.com/wshenjin/p/9935386.html


FROM centos

COPY ["src","/src"]

RUN groupadd -g 1000 www \
    && useradd -u 1000 -g www -s /sbin/nologin www ;\
    yum -y install \
    make \
    libtool \
    gcc gcc-c++\
    openssl openssl-devel \
    zlib zlib-devel \
    bzip2 \
    libmemcached libmemcached-devel \
    libevent libevent-devel \
    libxml2 libxml2-devel \
    libcurl libcurl-devel \
    libpng libpng-devel \
    freetype freetype-devel \
    libmcrypt libmcrypt-devel \
    pcre pcre-devel \
    libjpeg-turbo libjpeg-turbo-devel \
    && ldconfig \
    && yum clean all ;\
    cd /src/ \
    && tar xf php-5.6.30.tar.bz2 \
    && cd php-5.6.30 \
    && CHOST="x86_64-pc-linux-gnu" CFLAGS="-march=nocona -O2 -pipe" CXXFLAGS="-march=nocona -O2 -pipe" \ 
    ./configure --prefix=/usr/local/php \
    --enable-fpm  \
    --enable-mbstring \
    --enable-sockets \
    --enable-pdo \
    --enable-zip \
    --enable-fpm \
    --with-gd \
    --with-fpm-user=www \
    --with-fpm-group=www \
    --with-zlib \
    --with-config-file-path=/usr/local/php/etc \
    --with-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
    --prefix=/usr/local/php \
    --with-pcre-dir=/usr/lib64/ \
    --enable-soap \
    --with-openssl-dir=/usr/include/openssl \
    --with-openssl \
    --enable-mbstring \
    --enable-bcmath \
    --with-libxml-dir=/usr/lib64/ \
    --with-curl=/usr/lib64/ \
    --with-png-dir=/usr/lib64/ \
    --with-jpeg-dir=/usr/lib64/ \
    --with-freetype-dir=/usr/lib64/ \
    --with-gettext \
    && make -j`grep -c processor /proc/cpuinfo` > /dev/null \
    && make install > /dev/null \
    && cp -f /src/php-fpm.conf /usr/local/php/etc/php-fpm.conf \
    && cp -f /src/php56.ini /usr/local/php/etc/php56.ini \
    && ln -s /usr/local/php/etc/php56.ini /usr/local/php/etc/php.ini \
    && ln -sf /usr/local/php/etc/php.ini /etc/php.ini \
    && mkdir -p /data/{logs,web} \
    && chown www:www -R /data/logs /data/web \
    && echo "kill -USR2 \`cat /data/logs/php-fpm.pid\`" > /root/php-fpm_reload \
    && chmod 700 /root/php-fpm_reload ;\
    cd /src/ \
    && tar xf memcache-2.2.7.tgz \
    && cd memcache-2.2.7 \
    && /usr/local/php/bin/phpize \
    && CHOST="x86_64-pc-linux-gnu" CFLAGS="-march=nocona -O2 -pipe" CXXFLAGS="-march=nocona -O2 -pipe" \
    ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config \
    && make \
    && make install ;\
    cd /src/ \
    && tar xf memcached-2.2.0.tgz \
    && cd memcached-2.2.0 \
    && /usr/local/php/bin/phpize --clean \
    && /usr/local/php/bin/phpize \
    && ./configure --enable-memcached --with-php-config=/usr/local/php/bin/php-config \
    && make \ 
    && make install ;\
    cd / ;\
    rm -rf /src ;\
    yum remove -y iputils* iproute file make gcc cpp vim-minimal acl bind* rootfiles file \
    python-chardet gobject-introspection libxml2-python python-gobject-base basesystem libgomp \
    libstdc++-devel glibc-headers mpfr passwd yum-plugin-ovl dbus-glib python-kitchen kernel-headers \
    && yum clean all;\
    userdel mail ;\
    userdel ftp ;\
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/ ;\
    ln -svf /etc/Shanghai /etc/localtime ;\
    rm -rf /src /root/.bash* /root/.cshrc  /root/.tcshrc /var/cache /usr/share/zoneinfo 

EXPOSE 9000
CMD ["/usr/local/php/sbin/php-fpm","--fpm-config","/usr/local/php/etc/php-fpm.conf"]

PHP的配置文件php-fpm.conf,需要作如下调整:

[global]
daemonize = no
[www]
listen = 0.0.0.0:9000
;listen.allowed_clients = 0.0.0.0

这样允许PHP容器接收所有网卡的请求

posted @ 2018-11-09 15:29  wshenJin  阅读(1635)  评论(0编辑  收藏  举报