Adding a new App in Homestead

The Laravel doco has a section on how to add a new app to an existing vagrant box. It never seems to work for me, though, without a couple of extra steps.

One extra step is to add the new app to the .hosts file (/etc/hosts on a Mac, C:\Windows\System32\drivers\etc\hosts on a PC), thus:

# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
192.168.10.10  my-first.app
192.168.10.10  the-second.app
192.168.10.10  yet_another.app

(Or if you know what you’re doing you could use a magic DNS service like xip.io to handle DNS for you.)

The second is to get the right Homestead.yaml file, because on some of my machines there seem to be several. Otherwise vagrant provision won’t fix your problem. On my  boxes it seems to be C:\Vagrant\[your box name]\config\Homestead.yaml on a PC or /Applications/[your box name]/config/Homestead.yaml on a Mac. This is not what the doco says.

However I sometime have trouble getting vagrant provision to work  no matter which Homestead.yaml file I use. So then what I do is:

  1.  vagrant ssh in to the Vagrant box and
  2. Add a new file in /etc/nginx/sites-available
    1. Use one of the ones that’s already there as a template
    2. Change the server_name line,
    3. Change the root line, and
    4. Change the error_log line.
    5. Don’t change the two ssl_certificate lines unless you then want to go create a bunch of files in /etc/nginx/ssl/)
  3. Add a link to the new file in /etc/nginx/sites-enabled
  4. Don’t forget to sudo service nginx restart.

If that doesn’t work, check that your new HTML / PHP / whatever files have the right permissions.

And that (finally) seems to get the job done.

Advertisements
Adding a new App in Homestead

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s