症状
Laravel+Homestead+Vagrantで新しくプロジェクトを作り、welcomeページを表示(Homestead.yamlに書かれているipにアクセス)したところ、ブラウザに"No input file specified."と表示される。
そもそもipが間違っている時とはエラーメッセージが異なるので、どうやら接続はできているらしいことがわかる。
ホスト側のプロジェクトのディレクトリ構成
~/Laravel/Sample/laravelapp
仮想マシンのエラーの探し方
仮想マシンのエラーログを見るには、vagrant sshでログインし、下記を入力。
vim /var/log/nginx/homestead.test-error.log
下記のエラーが出ていた。
2019/04/20 17:20:36 [error] 3616#3616: *1 FastCGI sent in stderr: "Unable to open primary script: /home/vagrant/code/public/index.php (No such file or directory)" while reading response header from upstream, client: 192.168.10.1, server: homestead.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "homestead.test"
見に行っているフォルダにindex.phpがないということらしい。
index.phpはpublicディレクトリの下に配置されている。
vagrant sshでログインし、仮想マシンのディレクトリ構成を見てみると、publicフォルダは下記のパスに配置されていた。
code/laravelapp/public
一方、Homested.yamlのsitesの設定を見てみると、
Homestead.yaml
sites:
- map: homestead.test
to: /home/vagrant/code/public //間違っている!
下記のように直したところ、welcomeページに繋がるようになった。
Homestead.yaml
sites:
- map: homestead.test
to: /home/vagrant/code/laravelapp/public