构建Nginx和PHP镜像

  1. # Nginx Server
  2. # Version 1.18.0
  3. FROM centos:7
  4. MAINTAINER .com
  5. RUN yum -y install gcc gcc-c++ autoconf automake make wget pcre pcre-devel zlib-devel && \
  6. yum clean all && \
  7. rm -rf /var/cache/yum/*
  8. RUN wget http://nginx.org/download/nginx-1.18.0.tar.gz && \
  9. tar zxvf nginx-1.18.0.tar.gz && \
  10. cd nginx-1.18.0 && \
  11. ./configure --prefix=/usr/local/nginx && \
  12. make && make install && \
  13. cd ../ && \
  14. rm -rf nginx-1.18.0.tar.gz && \
  15. ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  16. ENV PATH $PATH:/usr/local/nginx/sbin
  17. WORKDIR /usr/local/nginx
  18. EXPOSE 80
  19. CMD ["nginx", "-g", "daemon off;"]
  1. # PHP-FPM
  2. # Version 7.2.33
  3. FROM centos:7
  4. MAINTAINER .com
  5. RUN yum -y install gcc gcc-c++ autoconf automake make wget libxml2-devel libpng libpng-devel && \
  6. yum clean all && \
  7. rm -rf /var/cache/yum/*
  8. RUN wget https://www.php.net/distributions/php-7.2.33.tar.gz && \
  9. tar zxvf php-7.2.33.tar.gz && \
  10. cd php-7.2.33 && \
  11. ./configure --prefix=/usr/local/php --enable-mysqlnd --with-mysqli=mysqlnd --enable-fpm --enable-gd-jis-conv --with-gd && \
  12. make && make install && \
  13. cd ../ && \
  14. rm -rf php-7.2.33.tar.gz && \
  15. rm -rf php-7.2.33 && \
  16. ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
  17. cd /usr/local/php && \
  18. cp ./etc/php-fpm.conf.default ./etc/php-fpm.conf && \
  19. cp ./etc/php-fpm.d/www.conf.default ./etc/php-fpm.d/www.conf
  20. WORKDIR /usr/local/php
  21. EXPOSE 9000
  22. CMD ["./sbin/php-fpm", "-F"]