12
13

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 5 years have passed since last update.

vagrant on mac にLaravel Homesteadを入れてみる

Posted at

Mac上のvmに、Laravel Homesteadを使って環境構築してみたメモ。

環境

 vagrant/virtualbox はインストール済み

boxを作る

$ vagrant box add laravel/homestead
==> box: Loading metadata for box 'laravel/homestead'
    box: URL: https://atlas.hashicorp.com/laravel/homestead
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) virtualbox
2) vmware_desktop

Enter your choice: 

virsualbox利用なので 1を選択

Enter your choice: 1
==> box: Adding box 'laravel/homestead' (v0.4.4) for provider: virtualbox
    box: Downloading: https://atlas.hashicorp.com/laravel/boxes/homestead/versions/0.4.4/providers/virtualbox.box
==> box: Successfully added box 'laravel/homestead' (v0.4.4) for 'virtualbox'!

終わり。

確認してみる。

$ vagrant box list
laravel/homestead (virtualbox, 0.4.4)

HomesteadのClone

git clone

ユーザのホームの下の/devディレクトリに、Homesteadをclone

$ cd ~/dev/
$ git clone https://github.com/laravel/homestead.git Homestead
Cloning into 'Homestead'...
remote: Counting objects: 1571, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 1571 (delta 0), reused 0 (delta 0), pack-reused 1565
Receiving objects: 100% (1571/1571), 244.01 KiB | 105.00 KiB/s, done.
Resolving deltas: 100% (924/924), done.
Checking connectivity... done.

初期化

$ cd Homestead/
$ bash init.sh
Homestead initialized!

設定

$ mkdir ~/dev/Homestead/Code

- map: ~/Code だけ
- map: ~/dev/Homestead/Code に変更

~/.homestead/Homestead.yaml
folders:
    - map: ~/dev/Homestead/Code
      to: /home/vagrant/Code

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public

databases:
    - homestead

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

SSHキー

なければ

$ ssh-keygen -t rsa

で作成

host追加

/etc/hosts
192.168.10.10   homestead.app

プロジェクト作成

vagrant起動

vagrant 起動してSSH接続、プロジェクトを作成する

$ vagrant up
$ vagrant ssh

vagrant上で

$ cd Code
$ composer create-project laravel/laravel --prefer-dist Laravel

/home/vagrant/Code/Laravel に新規プロジェクトができた。

で、見れない・・・・

provisionオプションをつける

mac上で

$ vagrant halt
$ vagrant up --provision

でオプションつきで起動する。

"Laravel 5" が表示されればOK!!

とりあえずここまで。


参考)
http://readouble.com/laravel/5/1/ja/homestead.html
http://qiita.com/ran/items/14053e3f3fb20ed7c38a
http://blog.hrendoh.com/setting-up-laravel-local-dev-environment-with-homestead/
https://laracasts.com/discuss/channels/laravel/how-can-access-my-laravel-project-from-my-homestead?page=1

12
13
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
12
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?