When using Laravel's Homestead, one thing that can be a pain is having to constantly re-add configuration rules in your site's nginx config upon provisioning. This is infinitely worse when you have to configure multiple sites 😤 . However with this setup, you can put those days behind you. The following instructions focus on location, however this can be applied to pretty much anything.
The location rule here pulls images from your live site if they don't exist on your local dev environment. Helps reduce GBs of unnecessary assets on your local machine In order for the following code to work, your site folder must have the same name as the live site.
-
Inside of the ~/Homestead/scripts folder, edit "serve-laravel.sh".
-
Insert the accompaning code in its respective places.
-
That's it!
-
Inside of the aforementioned scripts folder, make a copy the "server-laravel.sh" file and name it "serve-custom.sh".
-
Insert the accompaning code in its respective places.
-
Edit your Homestead.yaml and add a "type" property of "custom" inside of the site configuration area.
sites:
- map: yoursite.dev
to: /home/vagrant/Code/yoursite
type: custom
- FYI, type can be whatever you want it to be named, as long as "serve-{type}.sh" exists in the scripts folder. If not, defaults to "serve-laravel.sh".
Note: If your Homestead local repository is updated/changed to a new tag, there should be no merge conflicts if the alternative way is implemented.