This is likely because the nginx web server is not pointing to the right path.
There's two keys that you should look at: the map
key under folders
and the to
key under sites
. The folders
key maps folders on your local machine to the vagrant VM. The sites
key is used to create a virtual host on nginx with the value in to
.
What you want to make sure is that to
under sites
points to the right path to public
.
The problem was that I created my laravel project with composer create laravel/laravel
. This created a folder in my current directory named laravel
. Then without changing directories I installed the homestead helper with composer require laravel/homestead --dev
.
After running php vendor/bin/homestead make
and vagrant up
my directory structure looked something like this:
$ cd laravel51
$ ls -a
.
..
.vagrant
laravel
composer.json
composer.lock
vendor
Homestead.yml
Vagrantfile
My Homestead.yml looked like this:
folders:
- map: "/Users/USER/Sites/sandbox/php/laravel51"
to: "/home/vagrant/laravel51"
sites:
- map: laravel51
to: "/home/vagrant/laravel51/public"
If you look closely, the /Users/USER/Sites/sandbox/php/laravel51
path will be mounted onto the vagrant VM. This is the wrong directory because it should be pointing to the laravel project root where your app directory is. What happened here was that I was supposed to require the homestead helper while I was in the project root.
So now the question is what do I do? You've got two options: get rid of your current homestead VM and start over, but this time from the project root OR salvage what you have already.
If you want to salvage what you have, you'll have to move several files and a folder to your laravel project root.
These are the artifacts you'll need to move:
.vagrant
Homestead.yml
Vagrantfile
The composer.json
won't be needed since you'll be requiring it later.
Move those files to your laravel project root and change your current working directory to there (cd laravel
). At that point just update the map
under folders
and make sure that it's pointing to the project root. Also make sure that the to
key under sites
is the to
key under folders
with /public
appended to it.
For example:
folders:
- map: "/Users/USER/Sites/sandbox/php/laravel51/laravel"
to: "/home/vagrant/laravel51"
sites:
- map: laravel51
to: "/home/vagrant/laravel51/public"
Now run composer require laravel/homestead --dev
so that the homestead helper is required into your current project's composer.json file and installed.
Run vagrant reload --provision
and you should be all set.