Skip to content

Instantly share code, notes, and snippets.

@dgoguerra
Last active January 8, 2019 22:20
Show Gist options
  • Save dgoguerra/aabc3122d2079b05af4d0201c2e4f9c7 to your computer and use it in GitHub Desktop.
Save dgoguerra/aabc3122d2079b05af4d0201c2e4f9c7 to your computer and use it in GitHub Desktop.
Homestead v2.0.0 configuration

Installation

# download homestead repo
cd ~/code
git clone https://github.com/laravel/homestead.git homestead

cd homestead
# move to a release (see latest: https://github.com/laravel/homestead/releases)
git checkout v7.3.0
# add custom virtualbox settings which prevent the machine from hanging sometimes
wget -qO- https://gist.githubusercontent.com/dgoguerra/aabc3122d2079b05af4d0201c2e4f9c7/raw/Vagrantfile.diff | git apply

# initialize and edit Homestead.yaml
bash init.sh
nano Homestead.yaml # edit as needed

# start the machine. may take some time to download laravel/homestead box
vagrant up

To run any Vagrant command on your Homestead machine from any directory, add to your Bash profile (~/.bash_profile on OSX, ~/.bashrc on Linux) the following function (or homestead-custom.sh to add some helpers to the homestead command):

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

Optional

If you want to start downloading the Homestead box before configuring anything and running vagrant up, run:

vagrant box add laravel/homestead --provider virtualbox

Links

# Run Vagrant commands on the Homestead machine
function homestead() {
case "$1" in
# ssh directly into the current directory
ssh)
local absPath="$PWD"
local prefix="$HOME/"
local relPath="${absPath#$prefix}"
# try to cd into the relative path. fail silently if not found
( cd ~/code/homestead && vagrant ssh -- -t "cd \"$relPath\" 2>/dev/null; exec \$SHELL --login" )
;;
# open Homestead.yaml to edit it
edit)
open ~/code/homestead/Homestead.yaml
;;
*)
( cd ~/code/homestead && vagrant $* )
;;
esac
}
diff --git a/Vagrantfile b/Vagrantfile
index 12b8f52..7b77ab2 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -17,6 +17,11 @@ require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
Vagrant.require_version '>= 1.9.0'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+
+ config.vm.provider 'virtualbox' do |vb|
+ vb.customize ['modifyvm', :id, '--cableconnected1', 'on']
+ end
+
if File.exist? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
config.vm.provision "shell" do |s|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment