Laravel homesteadを使ってLaravel 5のローカル開発環境を構築

Index

What?

Why?

  • Laravel は、PHPのくせにNode.js諸々が必要だったりして、かなり環境構築が面倒
    • Vargrantを使って一気に環境を作れると便利!
    • Laravel環境に必要なものをhomesteadという名前のVagrantboxとしてまとめたぜ!

How to?

Step1: 事前準備

  • Vagrant と homesteadの初期化をしておく

  • ローカル開発環境(つまりはお手元のmac)で

    • Vagrant をインストール(時間かかる)
    • VagrantのHomestead boxをダウンロードしておく(時間かかる)
      • vagrant box add laravel/homestead
    • Homestead をcloneして、初期化(一瞬)
      • git clone https://github.com/laravel/homestead.git homestead
      • cd homestead; sh init.sh
        • ~/.homesteadディレクトリの中に設定ファイルがコピーされる

Step2: 設定

  • Homesteadの設定をする
    • ~/.homestead/Homestead.yaml を編集する
      • sites.map 以外はディフォルト
ip: "192.168.10.10" # VMのIPになる
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Develop/Trial/tryLaravel # ローカルでLaravelをインストールするorされているディレクトリ
      to: /home/vagrant/Code # VM内のディレクトリ

sites: # Nginxの設定
    - map: homestead.app # ドメイン設定、Hosts設定とつながる
      to: /home/vagrant/Code/Laravel/public # Laravelのpublicディレクトリの場所

databases:
    - homestead
  • ホストPCでHostsを追記(homestead.appドメインでアクセスするため
    • 再起動はいらないよー
192.168.10.10 homestead.app

Step3: VM立ち上げ

$ mkdir -p ~/Develop/Trial/tryLaravel
  • VMを立ち上げる
    • bootするのに数分かかる
$ cd ~/homestead/
$ vagrant up
  • 確認

Step4: Laravelインストール

  • ホストPCからゲストPCにsshログイン
$ vagrant ssh
  • ゲストPCで、Laravelインストール
$ cd ~/Code
$ composer create-project laravel/laravel --prefer-dist laravel

参考

Laravel homesteadを利用したLaravel 5 ローカル開発環境の構築 | hrendoh's memo

Laravel Homesteadを使ってみよう! - Qiita

Homestead.yamlの編集 | WinRoadのLaravel4初心者講座

Laravel homestead初期設定中に失敗したときのやり直し方

What?

  • Laravel homestead初期設定中に失敗したときのやり直し方

Why?

$ vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Running provisioner: file...
Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.

Solution

  • 一回殺してから、再起動
$ vagrant destroy
$ vagrant up

Mac で vagrant のバージョンアップをする

What?

  • Macvagrant のバージョンアップをする

Why?

  • Laravel環境をhomesteadで作ろうとしたらバージョン低すぎて怒られた
$ vagrant up
This Vagrant environment has specified that it requires the Vagrant
version to satisfy the following version requirements:

>= 1.8.4

Solution

  • 作業前
$ vagrant -v
Vagrant 1.8.1
  • Mac用のpkgをダウンロードしてGUIでインストールするだけ

https://www.vagrantup.com/downloads.html

  • 作業後
$ vagrant -v
Vagrant 1.9.1

Jenkins初期セットアップ時にプラグインがインストールできない

What?

Jenkins初期セットアップ時に以下エラーが表示され、プラグインがインストールできない。

An error occurred during installation: No such plugin: cloudbees-folder

Why?

まだ不明

Solution?

http://localhost:8080/restart でJenkinsを再起動する

or

service jenkins restart でJenkinsを再起動する

をやってみたけど、だめだったのでGetting startedをスキップしてしまった。継続調査中。

参考

stackoverflow.com

brew update で `/usr/local/Library/ENV/scm/git: No such file or directory` エラー

What?

brew cask updateしたら、gitがないエラーが出る。

$ brew cask update
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
==> Error: update-report should not be called directly!
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
  https://git.io/brew-analytics
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
Error: update-report should not be called directly!

Why?

github.com

Solution?

  • cd "$(brew --repository)" && git fetch && git reset --hard origin/master してから、もう一度実行する

参考

discuss.circleci.com

stackoverflow.com

Google ドライブで 「現在、ファイルを開くことができません。」

f:id:kz_engineer:20161013180749p:plain

What?

現在、ファイルを開くことができません。

アドレスを確認して、もう一度試してください。
Sorry, unable to open the file at this time.

Please check the address and try again.

会社でGoogle formで作っていたあるツールが突然この表示。検索しても、プラグインを殺せとか、ブラウザ変えろとか、そういうものばっかり。100人一気に見れなくなってるんだからそれはない。

Why?

フォームのオーナーのアカウントが手違いで消されたからだった。このあとアカウントなどなどを復活させました。

じゃあ、そういうエラーメッセージの表示をしてよ!w

自分のアカウントの情報漏洩確認サイト

大きい情報漏洩ニュースがあった時、自分のアカウントが漏洩しているか心配ですよね。

確認用サイト

f:id:kz_engineer:20160726113543p:plain

haveibeenpwned.com

僕の結果

  • 先日のLinkedInはじめ、大手2,3サイトほどの漏洩リストに入ってた。残念だ。
  • 即、パスワード変えました。