Docker配置PHP开发环境教程
Docker  /  管理员 发布于 4年前   623
前言 笔者用的是mac开发,但是mac自带的php功能安装十分不方便,并且和线上的linux开发环境不一致。在没有用docker之前一直用vagrant配置的centos的php开发环境,但是自从有了docker之后,就不再用vagrant了。 配置自己的php镜像 首先在自己的任意一个目录下创建如下三个文件 run.sh sources.list Dockerfile 执行命令 配置php mysql开发环境 www/index.php nginx.conf docker-compose.yml 开启php的测试项目 总结 以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。#!/bin/bash/usr/sbin/php-fpm7.0/usr/sbin/nginxtailf /etc/apt/sources.list
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricteddeb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial universedeb http://mirrors.aliyun.com/ubuntu/ xenial-updates universedeb http://mirrors.aliyun.com/ubuntu/ xenial multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-propertiesdeb http://archive.canonical.com/ubuntu xenial partnerdeb-src http://archive.canonical.com/ubuntu xenial partnerdeb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial-security universedeb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
FROM ubuntu:16.04# ===========================# 配置虚拟主机# -v default:/etc/nginx/sites-enabled/default# 配置程序目录# -v web:/var/www/html# 配置映射端口# -p 8008:80# ===========================MAINTAINER chengtao "[email protected]" ADD sources.list /etc/apt/sources.listADD run.sh /root/run.shRUN chmod +x /root/run.shRUN 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.iniRUN mkdir -p /run/php/EXPOSE 80 CMD ["/bin/bash","/root/run.sh"]
docker build -t d1studio:php-base:0.1 .
mkdir -p ~/projects/php-appcd ~/projects/php-appmkdir mysqlmkdir www
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; }}
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
#开启docker-compose up#关闭docker-compose down
您可能感兴趣的文章:
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号