---
# System prepended metadata

title: Laradock 部署多專案

---

# Laradock 部署多專案

## 前置準備

環境需有docker與docker-compose，如沒有請先安裝


*  clone laradock專案
 ```bash
 git clone https://github.com/laradock/laradock.git
 ```
 
*  laradock目錄內設置env
 ```bash
 cp env-example .env
 ```
 
*  下載laravel專案
 ```bash
 composer create-project laravel/laravel project_1 --prefer-dist
 ```
 
 設定laravel env
 ```env
 DB_CONNECTION=mysql
 DB_HOST=mysql
 DB_PORT=3306
 DB_DATABASE=laravel
 DB_USERNAME=root
 DB_PASSWORD=root
 ```
 
*  檔案結構
 ```
 ./
  ﹂ laradock/
  ﹂ project_1/
  ﹂ project_2/
  .
  .
  .
 ```
 
*  NGINX設定
 `/laradock/nginx/sites`
 
 `cp laravel.conf.example project_1.conf`
 
*  修改conf內參數
 例如：
 ```nginx
 server_name project1.dev
 root /var/www/project_1/public
 ```
 
*  加入本機hosts
 ```
 127.0.0.1  project1.dev
 127.0.0.1  project2.dev
 .
 .
 .
 ```
 
*  啟動
 ```bash
 docker-compose mysql nginx workspace
 ```
 
*  查看容器啟動狀態
 `docker-compose ps`