The Laravel Homestead virtual machine provides the ideal server configuration for a Laravel project.
With the Homestead repo https://github.com/laravel/homestead we can configure our Laravel (and non Laravel) projects.
Homestead is setup in the ~/
directory.
To run vagrant commands globally add this function to .bash_profile
.
function hs() {
cd ~/Homestead && vagrant "$*"
}
Remember to add each site to the hosts file.
Remember to backup any local databases first and add backup: true
to Homestead.yaml
. to backup the Homestead specific databases.
To update the base box run vagrant box update
from the Homestad directory.
This command updates the box defined in the directories Vagrantfile.
This update only downloads the new box it doesn't update the running virtual machine.
To pull in the latest source code run git fetch
from the Homestead directory.
To use the new base box vagrant destroy
and vagrant up
.
Check if the box is out of date with vagrant box outdated
. Add the box id as a parameter. Find the box id with vagrant global-status
To use the SSL certificate generated by nginx we need to add to the browser.
SSH into the server and copy the certificate to the project home directory.
cp /etc/nginx/ssl/LOCALSITEURL.crt /home/vagrant/code/LOCALSITEFOLDER
Or add this function to your .bash_profile
. Pass in two arguments. The local site url from Homestead.yaml sites:map and the local site directory from Homestead.yaml folders:map.
function hsssl {
cd ~/Homestead && vagrant ssh -c "cp /etc/nginx/ssl/$1.crt /home/vagrant/code/$2"
}
The certificate can then be added to the MacBook login certificates keychain and set to always trust.
Login details -u homestead -p secret