Docker_构建nginx+php-fpm环境

构建nginx+php-fpm环境

下载nginx-1.15.7到本地目录

http://nginx.org/en/download.html

http://nginx.org/download/nginx-1.15.7.tar.gz

DockerFile去掉里面的#注释

FROM centos:centos7
MAINTAINER ZQL.com
ENV TIME_ZOME Asia/Shanghai
ARG WJ="nginx-1.15.7"
#wget http://nginx.org/download/nginx-1.15.7.tar.gz
 
#COPY nginx.conf /usr/local/nginx/
ADD $WJ.tar.gz /tmp
RUN yum -y install net-tools
RUN yum -y install gcc gcc-c++ make openssl-devel pcre-devel zlib-devel \
        && useradd -s /sbin/nologin nginx  \    
        && mkdir -p /usr/local/nginx \
        && cd /tmp/$WJ \
        && ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-stream --with-http_ssl_module --with-http_stub_status_module \
        && make -j 4 \
        && make install \
        && echo "${TIME_ZOME}" > /etc/timezone \
        && ln -sf /usr/share/zoneinfo/${TIME_ZOME} /etc/localtime \
        && rm -rf /tmp/nginx* \
        && ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx  \
        && yum install -y epel-release  \
        && rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm \
        && yum -y install yum-utils  \
        && yum-config-manager --enable remi-php72  \
        && yum -y install php php72-php-opcache  php72-php-ldap php72-php-odbc php72-php-pear php72-php-xml php72-php-xmlrpc php72-php-soap curl curl-devel  php72-php-mbstring php72-php-mysqlnd  php72-php-fpm  php72-php-gd \
        && sed -i "s/apache/nginx/g"  /etc/opt/remi/php72/php-fpm.d/www.conf \  
        && yum clean all \
        && yum -y remove gcc gcc-c++ make \
        && chmod -R 777 /var/opt/remi/php72/lib/php/session/  
  
 
WORKDIR /usr/local/nginx/
EXPOSE 80
CMD /opt/remi/php72/root/sbin/php-fpm  && nginx -g "daemon off;"  

创建镜像

 docker build -f .\DockerFile6 -t nginx_php_centos .

指定端口,启动镜像

docker run -it -p 8080:80  --name=myphp nginx_php_centos /bin/bash

访问网址

127.0.0.1:8080

在这里插入图片描述
还可以设置共享目录,这样在win代码就可以直接运行了 -v

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

a...Z

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值