# 前提 安装 docker 同时安装 docker-compose Docker 官网 - [https://www.docker.com/](https://www.docker.com/) # 快速开始 Laradock 官网 - [http://laradock.io/](http://laradock.io/) 我们可以通过 Laradock 快速开启 NGINX, PHP, Composer, MySQL, Redis, Beanstalkd 等服务: 1 - 从 Github 克隆 Laradock 项目到你的机子上: ```bash cd ~ git clone https://github.com/Laradock/laradock.git ``` 2 - 进入 laradock 目录, 复制一份 env-example 为 .env ```bash cd laradock cp env-example .env ``` 3 - 启动你想要的服务容器: ```bash docker-compose up -d nginx mysql redis ``` 4 - 打开你的 PHP 项目, 修改 .env 中 mysql、redis 等连接地址: ```bash DB_HOST=mysql REDIS_HOST=redis ``` 5 - 打开浏览器查看效果 http://localhost. ```bash That's it! enjoy :) ``` # 更多使用方法 ## 通用方法, 如: 更改配置、版本、站点等 ```bash # 停止服务 例如 Nginx 上添加一个站点 www.achais.test docker-compose stop nginx # 添加站点配置文件 新增一个 Laradock 项目中 nginx/sites 目录下的配置文件 # 出现创建 nginx docker-compose build nginx # 重启服务 docker-compose up -d nginx ``` ## MySQL 服务 ```bash # 启动 docker-compose up -d mysql # 执行服务 bash docker-compose exec mysql bash # 接下来就和平时使用 MySQL 的命令一模一样了 $ mysql -uroot -p # Enter password: # Welcome to the MySQL monitor. Commands end with ; or \g. # Your MySQL connection id is 2 # Server version: 5.7.24 MySQL Community Server (GPL) # Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. # Oracle is a registered trademark of Oracle Corporation and/or its # affiliates. Other names may be trademarks of their respective # owners. # Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. $ mysql> show databases; ```