Skip to content

Instantly share code, notes, and snippets.

@malinky
Last active February 27, 2019 12:22
Show Gist options
  • Save malinky/08e7aa2ecf8ddd3b038ff2006bd99aaa to your computer and use it in GitHub Desktop.
Save malinky/08e7aa2ecf8ddd3b038ff2006bd99aaa to your computer and use it in GitHub Desktop.
Laravel Homestead

LARAVEL HOMESTEAD

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.

Update

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

SSL

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.

MySQL

Login details -u homestead -p secret

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment