基于homestead-docker的PHP开发环境
1. 安装docker环境,for win
2. clone homestead for docker的package:git clone https://github.com/shincoder/homestead-docker.git
3. pull homestead image: docker pull shincoder/homestead:php7.1
4. copy && edit docker-compose.yml
$ cp docker-compose.dist.yml docker-compose.yml $ vim docker-compose and like follow
5. 连接web容器:
# 密码是secret ssh homestead@localhost`
6. 连接数据库:
# 密码为docker-compose.yml上的 【MYSQL_ROOT_PASSWORD: 'root'】即:root # or 有可能是密码为空,即直接: `mysql -uroot -p` 直接回车 mysql -uroot -p
如下是我homestead-docker.yml的配置:
web: image: shincoder/homestead:php7.0 restart: unless-stopped ports: - "80:80" # web - "22:22" # ssh volumes: - f:/works/.composer:/home/homestead/.composer # composer caching - f:/works/.gitconfig:/home/homestead/.gitconfig # Git configuration ( access alias && config ) - f:/works/.ssh:/home/homestead/.ssh # Ssh keys for easy deployment inside the container - f:/works/web:/apps # all apps - f:/works/nginx/sites-available:/etc/nginx/sites-available # nginx sites ( in case you recreate the container ) - f:/works/nginx/sites-enabled:/etc/nginx/sites-enabled # nginx sites ( in case you recreate the container ) - f:/works/nginx/ssl:/etc/nginx/ssl links: - mysql mysql: image: mysql:5.7 restart: unless-stopped ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: 'root' volumes: - f:/docker/mysql:/var/lib/mysql
说明:
- 该docker-compose.yml有
web
跟mysql
两个容器 image
字段: 标识使用的镜像的名称,可以切换,homestead-docker包的作者提供了php5.6/7.0/7.1版本ports
字段: 是端口的映射。第一个80
是本机的80
端口;第二个80
是指容器内部的80
端口volumes
字段:是指数据卷的映射。f:/works/.composer:/home/homestead/.composer
:表示以冒号(:)
分割,拆分为f:/works/.composer
(表示本机的目录) 跟/home/homestead/.composer
(表示容器内部的目录地址)。
原文
相关推荐
独行者0 2020-05-10
木马屠城 2020-05-09
xsgnzb 2019-09-03
韩吉鑫 2019-07-01
标题 2019-07-01
LipperZ 2019-06-28
cxymds 2019-06-28
wishy 2019-06-28
superhosts 2019-06-28
时间猎人 2019-06-27
时间猎人 2019-06-27
cxymds 2019-06-26
wxtyixiao 2019-06-26
zhuifengtjy 2019-06-25
Colphin 2019-06-25
标题 2019-06-25
时间猎人 2019-06-21
怕什么真理无穷 2019-06-21
LipperZ 2019-06-21