0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

laradocker構築

Posted at

##初めてdockerlaravelを構築したのでその手順をまとめた

###1.Laradock取得

$mkdir ~/my_docker
$cd ~/my_docker
$git clone https://github.com/laradock/laradock.git

###2.Laradockの設置ファイル修正

$cd Laradock
$cp env-example .env
$cp mysql/docker-entrypoint-initdb.d/createdb.sql.example mysql/docker-entrypoint-initdb.d/createdb.sql
.env
//修正することで別プロジェクトで競合を防ぐ
-DATA_PATH_HOST=~/.laradock/data
+DATA_PATH_HOST=~/.laradock/my_docker_project/data

//こちらも競合を防ぐ
-COMPOSE_PROJECT_NAME=laradock
+COMPOSE_PROJECT_NAME=my_docker-laradock

-MYSQL_VERSION=latest
+MYSQL_VERSION=5.7

###3.Laradockビルド・アクセス

$cd ~/my_docker/laradock
$docker-compose build workspace ngnix mysql redis
$docker-compose up -d ngnix mysql redis

立ち上がればworksqaceサーバへアクセス

$docker-compose exec workspace bash

###4.Laravel・yarnインストール
workspaceサーバ内で書きコマンドを実行

$ composer create-project laravel/laravel --prefer-dist laravel //laravelインストール。プロジェクト名laravel
$cd laravel
$yarn install  //yarnインストール

###5.Laravel設定ファイル修正
laradocker内の.envファイルと合わせる
こちらはlaravelの.envファイル

.env
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=default
DB_USERNAME=default
DB_PASSWORD=secret

###6.ブラウザアクセス

hosts修正

$sudo vi /private/etc/hosts
private/etc/hosts
+127.0.01 my_docker.com

####アクセス
ブラウザで http://my_docker.com へアクセスしlaravelが表示されれば完了

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?