1
1

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ローカル開発環境構築メモ(laravel/homestead)

Last updated at Posted at 2018-11-22

Laravelのローカル環境をLaravel Homesteadで構築した際の自分用メモ

前提条件

  • Windows 10 Enterprise
  • VirtualBox version 5.2.22
  • Vagrant version 2.2.0
    • vagrant-vbguest version 0.16.0
  • cygwin version 2.10.0-1
  • git version 2.17.0
  • rsync version 3.1.2

手順

ディレクトリ作成

mkdir hoge
cd hoge
// laravelのプロジェクトの共有ディレクトリとする
mkdir app

Homestead Vagrant Boxのインストール

  • 使用するプロバイダを聞かれるので、virtualboxを選択する
  • 以下のようなエラーが出る場合は、再度コマンド実行すれば、途中から再開可能
    • OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
vagrant box add laravel/homestead

Homesteadのインストール

git clone https://github.com/laravel/homestead.git
cd homestead
git checkout v7.19.2

Homestead.yamlの設定

bash init.sh
copy Homestead.yaml Homestead.yaml.org
vi Homestead.yaml
diff.txt
diff Homestead.yaml.org Homestead.yaml
4c4
< cpus: 1
---
> cpus: 2
13,14c13,14
<     - map: ~/code
<       to: /home/vagrant/code
---
>     - map: ../app
>       to: /home/vagrant/hoge
17,18c17,19
<     - map: homestead.test
<       to: /home/vagrant/code/public
---
>     - map: hoge.local
>       to: /home/vagrant/hoge/public
>       php: "7.2"
21c22
<     - homestead
---
>     - hoge

Vagrant 起動

vagrant up

仮想環境にSSH接続

vagrant ssh

laravelプロジェクト作成

cd /home/vagrant/
composer create-project --prefer-dist laravel/laravel hoge

動作確認

  • ホストPCからhttp://192.168.10.10/にアクセスして、以下の画面が表示されればOK
    laravel-welcome.PNG
  • hostsを編集すれば、http://hoge.local/でアクセス可能
    • C:\Windows\System32\drivers\etc\hosts
# hoge
192.168.10.10 hoge.local

おまけ

  • タイムゾーン変更(UTC→JST)
sudo timedatectl set-timezone Asia/Tokyo
  • ngrokで外部公開
ngrok http 80
  • IDEでコード補完するために
cd /home/vagrant/hoge
composer require --dev barryvdh/laravel-ide-helper
php artisan ide-helper:generate
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?