代码拉取完成,页面将自动刷新
FROM centos:7
# 维护者
MAINTAINER Tony <cheerfultony@gmail.com>
# 设置 PHP 版本 及 PATH(固化环境变量)
ENV PHP_VERSION 7.1.5
ENV PATH /usr/local/php/bin:/usr/local/php/sbin:$PATH
# 切换工作目录
WORKDIR /tmp
# 设置yum源
RUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
COPY CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
RUN yum clean all \
&& yum makecache
# 调整时区(有bug)
# timedatectl set-timezone Asia/Shanghai
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 关闭SELinux
# 关闭防火墙
# 解压swoole和redis包
ADD ./swoole-swoole-v4.2.2.tar.gz /tmp
ADD ./phpredis-php7.tar.gz /tmp
RUN set -x \
&& yum update -y \
&& yum install epel-release -y \
# centos7 下 yum安装libmcrypt会有找不到的情况,需要手动安装
&& yum install -y wget git gcc gcc-c++ make automake autoconf perl file tar re2c libjpeg libpng libjpeg-devel libpng-devel libjpeg-turbo freetype freetype-devel \
libcurl-devel libxml2-devel libjpeg-turbo-devel libXpm-devel libXpm libicu-devel libmcrypt-devel libxslt-devel libxslt openssl openssl-devel bzip2-devel pcre-devel \
# 编译 PHP
&& wget http://cn2.php.net/distributions/php-$PHP_VERSION.tar.gz \
&& tar -zxf php-$PHP_VERSION.tar.gz \
&& cd php-$PHP_VERSION \
&& ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc/ \
--with-config-file-scan-dir=/usr/local/php/conf.d/ \
--enable-fpm \
--enable-cgi \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--disable-phpdbg \
--enable-mbstring \
--enable-calendar \
--with-xsl \
--with-openssl \
--enable-soap \
--enable-zip \
--enable-shmop \
--enable-sockets \
--with-gd \
--with-freetype-dir=/usr/include/freetype2/freetype \
--with-jpeg-dir \
--with-png-dir \
--with-xpm-dir \
--with-xmlrpc \
--enable-pcntl \
--enable-intl \
--with-mcrypt \
--enable-sysvsem \
--enable-sysvshm \
--enable-sysvmsg \
--enable-opcache \
--with-iconv \
--with-bz2 \
--with-curl \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib \
--with-gettext \
&& make \
&& make install \
# 复制配置文件
&& cp /tmp/php-$PHP_VERSION/php.ini-production /usr/local/php/etc/php.ini \
&& cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
&& cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf \
&& echo 'extension=swoole.so' >> /usr/local/php/etc/php.ini \
&& echo 'extension=redis.so' >> /usr/local/php/etc/php.ini \
# 加入环境变量
# && echo "export PATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH" >> /etc/profile \
# && source /etc/profile \
# 安装swoole
&& cd /tmp/swoole \
&& phpize \
&& ./configure \
&& make \
&& make install \
# 安装redis
&& cd /tmp/phpredis-php7 \
&& phpize \
&& ./configure \
&& make \
&& make install \
# 安装 composer 由于composer下载慢或失败的问题,这里不进行安装
# 删除安装文件
&& rm -rf /tmp/* \
&& yum clean all \
&& rm -rf /var/cache/yum \
# 创建对外目录
&& mkdir /root/log \
&& mkdir /root/apps
WORKDIR /root
CMD [ "php", "./apps/server.php" ]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。