2
2

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.

[Laravel][Vagrant] laravel/homestead を利用する際に、Vagrant の box のバージョン遡って導入した手順の例

Posted at

前置き

LaravelをMacに入れようとして、PHPのバージョンやMySQLを調整していたら、バグがひどくなってきて既存の開発環境を壊しかねなかったので、Vagrantを使って、環境を分けることにしました。

laravel/homestead

laravelにはlaravel/homesteadという便利なboxが既にあって、公式で取り上げられているのでこれをつかいます

問題

laravel/homesteadの最新はv0.6.0で、PHPは7を使っています。詳しい情報をたどるのは結構手間ですが、この辺から、バージョンを遡ってみたりしいきました。

PHPは5.6を使いたいので、v0.3.3を使う必要があります。

$ vagrant box add laravel/homestead --box-version 0.3.3 # とにかく時間がかかるのでひたすら待ちます
==> 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: 1
==> box: Adding box 'laravel/homestead' (v0.3.3) for provider: virtualbox
    box: Downloading: https://atlas.hashicorp.com/laravel/boxes/homestead/versions/0.3.3/providers/virtualbox.box
==> box: Successfully added box 'laravel/homestead' (v0.3.3) for 'virtualbox'!

$ vagrant box list | grep homestead
laravel/homestead  (virtualbox, 0.3.3)

Install

Download

githubからcloneするなら

$ git clone https://github.com/laravel/homestead.git Homestead

もしくは以下からダウンロード

https://github.com/laravel/homestead/releases

Create Homestead.yaml

$ bash init.sh

~/.homestead 以下にできます

Vagrant立ち上げ

Homestead.yamlをいい感じに設定

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Homestead
      to: /home/vagrant/Code
      type: "nfs"

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

databases:
    - homestead

variables:
    - key: APP_ENV
      value: local

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

# ports:
#     - send: 93000
#       to: 9300
#     - send: 7777
#       to: 777
#       protocol: udp

homestead.yamlにbox versionを記述

provider: virtualbox
  version: "0.3.3"

/etc/hosts

192.168.10.10  homestead.app

vagrant up

$ vagrant up

アクセス

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?