dockerfile 安装启动nginx+php
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了dockerfile 安装启动nginx+php,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1841字,纯文字阅读大概需要3分钟。
内容图文
![dockerfile 安装启动nginx+php](/upload/InfoBanner/zyjiaocheng/941/e41eac88e4a64df6b83c00967319295a.jpg)
dockerfile脚本
FROM centos:latest
MAINTAINER https://blog.csdn.net/lituxiu
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 gcc gcc-c++ make openssl-devel pcre-devel zlib-devel && useradd -s /sbin/nologin nginx \ #创建nginx用户关联nginx和php-fpm程序
&& 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
#php是直接用第三方yum源epel安装的,指定安装7.2版本
&& 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 \
#把php-fpm的www.conf配置里的user和group都nginx
&& yum clean all && yum -y remove gcc gcc-c++ make && chmod -R 777 /var/opt/remi/php72/lib/php/session/
#设置权限php的session目录权限,否则跑项目里,会提示"Permission denied"
WORKDIR /usr/local/nginx/
EXPOSE 80
CMD /opt/remi/php72/root/sbin/php-fpm && nginx -g "daemon off;"
#上一行CMD同时启动php-fpm服务,不过最后一个服务一定要前台运行,要不创建的镜像后台会启动不起来(docker容器运行的原理)
内容总结
以上是互联网集市为您收集整理的dockerfile 安装启动nginx+php全部内容,希望文章能够帮你解决dockerfile 安装启动nginx+php所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。