#定义基础镜像
FROM ubuntu
#定义用户
MAINTAINER zyz
#定义ngxin配置信息
ENV CONFIG "\
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysqli \
--with-pdo-mysql \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--with-mcrypt \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--disable-fileinfo \
--enable-maintainer-zts \
--with-freetype-dir=/usr/ \
--enable-gd-native-ttf \
"
#安装必要组件
RUN apt-get update ; \
apt-get install -y tar ; \
apt-get install -y wget ; \
apt-get install -y gcc ; \
apt-get install -y libxml2-dev ; \
apt-get install -y libpng-dev ; \
apt-get install -y libjpeg-dev ; \
apt-get install -y openssl; \
apt-get install -y pkg-config; \
apt-get install -y libssl-dev; \
apt-get install -y bzip2; \
apt-get install -y libcurl4-gnutls-dev; \
apt-get install -y libfreetype6-dev; \
apt-get install -y libmcrypt-dev; \
apt-get install -y autoconf; \
apt-get install -y make
#下载安装包和补丁
COPY ./php-7.0.8.tar.gz ./php-7.0.8.tar.gz
# 准备安装环境
RUN \
#添加php用户和群组
groupadd www \
&& useradd -g www www \
#添加对应nginx放置文件地址
&& mkdir -p /usr/local/php/ \
&& mkdir -p /usr/local/php/etc/ \
&& mkdir -p /var/log/php/
#设置配置信息
RUN export PHP_OPENSSL_DIR=yes
#解压并编译安装
RUN tar -xzvf php-7.0.8.tar.gz \
&& rm -rf php-7.0.8.tar.gz \
&& cd php-7.0.8 \
#编译安装
&& ./configure $CONFIG \
&& make \
&& make install \
&& cd /usr/local/php/etc \
&& cp php-fpm.conf.default php-fpm.conf
#安装phpredis
RUN cd /tmp
COPY ./phpreidsNew.tar.gz ./phpreidsNew.tar.gz
RUN tar -xzvf phpreidsNew.tar.gz \
&& rm -rf phpreidsNew.tar.gz \
&& cd ./phpredis \
&& /usr/local/php/bin/phpize \
&& ./configure --with-php-config=/usr/local/php/bin/php-config \
&& make && make install
#安装xdebug扩展
RUN cd /tmp
COPY ./xdebug-2.4.0.tgz ./xdebug-2.4.0.tgz
RUN tar -xzvf xdebug-2.4.0.tgz \
&& rm -rf xdebug-2.4.0.tgz \
&& cd ./xdebug-2.4.0 \
&& /usr/local/php/bin/phpize \
&& ./configure --with-php-config=/usr/local/php/bin/php-config \
&& make && make install
#复制配置文件
COPY ./etc/php.ini /usr/local/php/etc/php.ini
#定义外部端口
EXPOSE 9000
#启动php,保留一个前台进程,以免被docker强制退出
CMD /usr/local/php/sbin/php-fpm