HomesteadでLaravel環境構築
LaravelのWelcome画面が表示されるまでの手順.
環境
- Mac
事前に導入しておく
- Git
- VIrtualBox
- Vagrant
環境構築手順
Homesteadを利用する。
Download Homestead
# vagrant box add laravel/homestead
プロバイダはvirtualbox を選択
ホームディレクトリに移動しGitからクローン
# cd ~
# git clone https://github.com/laravel/homestead.git Homestead
Initialize Homestead
Homestead 初期化
# cd ~/Homestead
# bash init.sh
作成するVMの設定を変更
Homestad.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/code
to: /home/vagrant/code
sites:
- map: homestead.test
to: /home/vagrant/code/sampleapp/public #変更
databases:
- homestead
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# zray:
# If you've already freely registered Z-Ray, you can place the token here.
# - email: foo@bar.com
# token: foo
# Don't forget to ensure that you have 'zray: "true"' for your site.
ディレクトリ作成
# cd ~
# mkdir code
macのホストに追加
# vi ~/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
192.168.10.10 homestead.test # 追加
Vagrant 起動
# cd ~/Homestad
# vagrant up
# vagrant ssh
# cd ~/code/
# composer create-project laravel/laravel sampleapp --prefer-dist "5.5.*"
ブラウザからアクセス
http://homestead.test