设为首页 收藏本站
查看: 619|回复: 0

[经验分享] dockerfile自动部署nginx+php7

[复制链接]
YunVN网友  发表于 2018-11-15 06:02:31 |阅读模式
FROM centos:7  
MAINTAINER Carl
  

  

  
#====================================解决依赖关系============================================
  

  
ENV NGINX_VERSION 1.10.2
  
ENV PHP_VERSION 7.0.12
  
ENV LIBICONV_VERSION 1.14
  

  
RUN yum -y install bzip* libm* mhash* \
  ImageMagick* php-pear* php-devel* \
  autoconf automake openssh  libiconv* \
  libreoffice-headless  libreoffice-writer lua* \
  libtool cmake make --skip-broken  && \
  yum clean all
  

  
#=============================================================================================
  
#
  
RUN rpm -ivh http://dl.fedoraproject.org/pub/epel/7Server/x86_64/e/epel-release-7-8.noarch.rpm && \
  yum install -y wget \
  wget zlib-devel zlib* \
  python-setuptools openssh* libmcrypt* \
  freetype-devel libpng-devel libjpeg-devel \
  pcre-devel lrzsz* gcc* image* openoffice* \
  libxslt-devel   freetype-devel  libpng-devel   \
  libcurl-devel openldap* postgresql-devel \
  curl-devel bzip2-devel  libjpeg-devel  readline-devel \
  libmcrypt* glibc* libcurl* \
  screen tree lsof htop iptraf  sysstat inotify-tools  htop\
  mcrypt* libevent* libxml2* \
  post* pcre* gcc-c++ && \
  yum clean all
  

  
#====================================安装nginx && php7=========================================
  
RUN groupadd -r www && \
  
    useradd -M -s /sbin/nologin -r -g www www
  

  

  
#download nginx libiconv and php7,libiconv1.14版本存在BUG
  
RUN mkdir -p /usr/local/src/nginx-php && cd $_ && \
  wget -c -O nginx.tar.gz http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz && \
  wget -O php.tar.gz http://php.net/distributions/php-$PHP_VERSION.tar.gz && \
  wget -c -O libiconv.tar.gz http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz && \
  curl -O -SL https://github.com/xdebug/xdebug/archive/XDEBUG_2_4_0RC3.tar.gz
  

  

  
#Make install nginx
  
RUN cd  /usr/local/src/nginx-php && \
  tar -zxvf nginx.tar.gz && \
  cd nginx-$NGINX_VERSION && \
  
        ./configure --prefix=/usr/local/nginx \
  
        --user=www --group=www \
  
        --error-log-path=/var/log/nginx_error.log \
  
        --http-log-path=/var/log/nginx_access.log \
  
        --pid-path=/var/run/nginx.pid \
  
        --with-pcre \
  
        --with-http_ssl_module \
  
        --without-mail_pop3_module \
  
        --without-mail_imap_module \
  
        --with-http_gzip_static_module && \
  
        make && make install
  

  
#Make install libiconv,存在BUG可修复
  
#stdio.in.h找到
  
#_GL_WARN_ON_USE (gets,"gets is a security hole - use fgets instead");
  
#注释掉
  
#添加
  
##ifdefined(__GLIBC__)&&!defined(__UCLIBC__)&&!__GLIBC_PREREQ(2,16)
  
# _GL_WARN_ON_USE (gets,"gets is a security hole - use fgets instead");
  
##endif
  
RUN cd  /usr/local/src/nginx-php && \
  tar -zxvf libiconv.tar.gz && \
  cd libiconv-$LIBICONV_VERSION && \
  ./configure --prefix=/usr/local/libiconv && \
  make -j 4 && make install
  

  

  
#Make install php7
  
RUN cd  /usr/local/src/nginx-php && \
  
        tar -zvxf php.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/etc/php.d \
  
        --with-fpm-user=www \
  
        --with-fpm-group=www \
  
        --with-mcrypt=/usr/include \
  --with-iconv=/usr/local/libiconv \
  
        --with-mysqli \
  
        --with-pdo-mysql \
  
        --with-openssl \
  
        --with-gd \
  
        --with-zlib \
  
        --with-gettext \
  
        --with-curl \
  
        --with-png-dir \
  
        --with-jpeg-dir \
  --with-freetype-dir \
  
        --with-xmlrpc \
  
        --with-mhash \
  --with-openssl \
  
        --enable-fpm \
  
        --enable-xml \
  
        --enable-shmop \
  
        --enable-sysvsem \
  
        --enable-inline-optimization \
  
        --enable-mbregex \
  
        --enable-mbstring \
  
        --enable-ftp \
  
        --enable-gd-native-ttf \
  
        --enable-mysqlnd \
  
        --enable-pcntl \
  
        --enable-sockets \
  
        --enable-zip \
  
        --enable-soap \
  
        --enable-session \
  
        --enable-opcache \
  
        --enable-bcmath \
  
        --enable-exif \
  
        --enable-fileinfo \
  
        --disable-rpath \
  
        --disable-debug \
  
        --without-pear && \
  
        make -j 4 && make install
  

  

  
#=======================================================================================================
  
#
  
#Add xdebug extension
  
RUN cd /home/nginx-php && \
  
    tar -zxvf XDEBUG_2_4_0RC3.tar.gz && \
  
    cd xdebug-XDEBUG_2_4_0RC3 && \
  
    /usr/local/php/bin/phpize && \
  
    ./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config && \
  
    make && \
  
    cp modules/xdebug.so /usr/local/php/lib/php/extensions/xdebug.so
  

  
RUN     cd /home/nginx-php/php-$PHP_VERSION && \
  
    cp 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
  
#
  
#=======================================================================================================
  
#Install supervisor
  
RUN easy_install supervisor && \
  
    mkdir -p /var/log/supervisor && \
  
    mkdir -p /var/run/sshd && \
  
    mkdir -p /var/run/supervisord
  

  
#Add supervisord conf
  
ADD supervisord.conf /etc/supervisord.conf
  

  
#Create web folder
  
VOLUME ["/data/www", "/usr/local/nginx/conf/ssl", "/usr/local/nginx/conf/vhost", "/usr/local/php/etc/php.d"]
  
ADD index.php /data/www/index.php
  

  
ADD xdebug.ini /usr/local/php/etc/php.d/xdebug.ini
  

  
#Update nginx config
  
ADD nginx.conf /usr/local/nginx/conf/nginx.conf
  

  
#========================向容器中添加文件===============================
  
#Start
  
ADD start.sh /start.sh
  
RUN chmod +x /start.sh
  

  
#======================指定容器映射到主机的端口=========================
  
#Set port
  
EXPOSE 8080 443 9000
  

  
#========================================================
  
#Start it
  
ENTRYPOINT ["/start.sh"]



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-635084-1-1.html 上篇帖子: Nginx自学手册(三)location匹配,rewrite 下篇帖子: LEMP:Nginx+mysql+php+xcache基于phpmyadmin管理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表