大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
怎么在Docker中配置一个PHP开发环境?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
站在用户的角度思考问题,与客户深入沟通,找到永善网站设计与永善网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都做网站、成都网站设计、企业官网、英文网站、手机端网站、网站推广、域名注册、虚拟主机、企业邮箱。业务覆盖永善地区。配置自己的php镜像
首先在自己的任意一个目录下创建如下三个文件
run.sh
#!/bin/bash /usr/sbin/php-fpm7.0 /usr/sbin/nginx tailf /etc/apt/sources.list
sources.list
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
Dockerfile
FROM ubuntu:16.04 # =========================== # 配置虚拟主机 # -v default:/etc/nginx/sites-enabled/default # 配置程序目录 # -v web:/var/www/html # 配置映射端口 # -p 8008:80 # =========================== MAINTAINER chengtao "751753158@qq.com" ADD sources.list /etc/apt/sources.list ADD run.sh /root/run.sh RUN chmod +x /root/run.sh RUN apt-get update RUN apt-get install -y php-fpm php-mysql nginx RUN sed -i 's/;date.timezone =/date.timezone = Asia\/Shanghai/' /etc/php/7.0/fpm/php.ini RUN mkdir -p /run/php/ EXPOSE 80 CMD ["/bin/bash","/root/run.sh"]
执行命令
docker build -t d1studio:php-base:0.1 .
配置php mysql开发环境
mkdir -p ~/projects/php-app cd ~/projects/php-app mkdir mysql mkdir www
www/index.php
nginx.conf
server { listen 80 default_server; root /var/www/html; index index.html index.htm index.php; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } }docker-compose.yml
version: '2' services: mysql: image: mysql:5.6 volumes: - ./mysql/:/var/lib/mysql/ ports: - "3307:3306" environment: - MYSQL_ROOT_PASSWORD=123456 php-app: image: d1studio/php-base:0.1 ports: - "8009:80" volumes: - ./nginx.conf:/etc/nginx/sites-enabled/default - ./www/:/var/www/html/ links: - mysql开启php的测试项目
#开启 docker-compose up #关闭 docker-compose down看完上述内容,你们掌握怎么在Docker中配置一个PHP开发环境的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!
新闻标题:怎么在Docker中配置一个PHP开发环境-创新互联
文章链接:http://dzwzjz.com/article/dpjcod.html