Homestead

Homestead is a Vagrant box that simplifies creating a PHP/MySQL/nginx environment.

Install

I put Homestead here (the default place):

cd ~/Homestead

Configure

Add the folder and site mappings:

# Edit with nano
nano ~/.homestead/Homestead.yaml

# Or edit with Atom
atom ~/.homestead/Homestead.yaml

Update hosts file:

sudo nano /etc/hosts

Reload the Homestead (Vagrant) box:

homestead reload --provision

Reference

Using the VM

# Change directory
cd ~/Homestead

# Start the VM
vagrant up

# Provision the VM (won't lose your data)
vagrant provision

# Provision something stubborn
vagrant reload --provision

# SSH into the VM
vagrant ssh

# Stop the VM
vagrant suspend

Make an alias

It’s annoying having to leave your project directory to start the VM. Add a function to your bash profile:

function homestead() {
    ( cd ~/Homestead && vagrant $* )
}

Now you can be inside any folder and run these:

homestead up
homestead provision
homestead reload --provision
homestead ssh
homestead suspend

Reference

Update

cd ~/Homestead

# Update the Git repo
git pull

# Update the vagrant box
vagrant box update

Platform tricks

For Laravel

Works great. Homestead was made by Laravel.

For Statamic

Works great with one modification for the Statamic admin.

Edit ~/Homestead/scripts/serve-laravel.sh and find this code:

location / {
    # GravDept: add this line for Statamic
    rewrite ^/admin.php.*$ /admin.php;
    # GravDept: end

    try_files \$uri \$uri/ /index.php?\$query_string;
}

Remember to run homestead provision afterward.

Reference