LoginSignup
3
4

More than 5 years have passed since last update.

LaravelのHomesteadを試す

Posted at

Homestead

LaravelではHomesteadというローカル開発環境VMが用意されているので使ってみる。
Lumen(Laravel製マイクロFW)でも使えるみたいなので、とりあえず環境を構築しておく。

公式ドキュメント: Laravel Homestead

環境

  • Mac(OSX10.11)
  • Vagrant
  • VirtualBox

Included Software

Homesteadに含まれるもの

  • Ubuntu 14.04
  • Git
  • PHP 7.0
  • HHVM
  • Nginx
  • MySQL
  • Sqlite3
  • Postgres
  • Composer
  • Node (With PM2, Bower, Grunt, and Gulp)
  • Redis
  • Memcached
  • Beanstalkd

VagrantBox

# vagrant box add laravel/homestead

実行時に、プロバイダー(virtualboxとかVMWareとか)を聞かれるので、表示される番号を入力する。

インストール

globalインストールだと~/に設定ファイル作成してしまうので、プロジェクトごとにインストールする方法を採用。

# mkdir homestead
# cd homestead
# curl -sS https://getcomposer.org/installer | php
# php composer.phar require laravel/homestead --dev

設定ファイルを確認

Homestead.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
hostname: homestead
name: homestead
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: "/Users/terada/dev/api/laravel/homestead"
      to: "/home/vagrant/homestead"

sites:
    - map: homestead.app
      to: "/home/vagrant/homestead/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

hostsを変更しておく

/etc/hosts
192.168.10.10    homestead.app

makeコマンド実行してVM起動

# php vendor/bin/homestead make
# vagrant up

動作確認

# vagrant ssh
$ cd /home/vagrant/homestead/
$ mkdir public
$ echo -e "<?php\nphpinfo();" > public/info.php
$ chmod 755 public/info.php

ブラウザでhttp://homestead.app/info.phpが表示されればOK.

3
4
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
3
4