Update: 2015-11-11 – I’ve finished porting over the PHP 7 branches of settler and homestead. If you want to use PHP 7, follow the instructions on the standard Laravel docs site and here, except use
johnpbloch/homestead-7 as your box instead of
Hello my friend,
I see repository on github about hyperv configuration to vagrant up. What are the commands to start the new machine on HyperV?
I really can’t see any good reason not to share the info with the rest of the world too, so I figured I’d put it in a blog post for the edification of everybody.
Before getting into the specifics of running the VM, I’ll talk about my setup a little bit first.
I’m using Vagrant 1.7.4. You will need at least 1.7.3 to use my Homestead setup (there were some major bugs on Windows that were fixed in that version). The HyperV provider comes bundled with Vagrant, so there’s no need to worry about installing it.
One of the things about HyperV is that you can’t set a static IP address for your machines. This makes it difficult to have instructions for adding hosts to
/etc/hosts. Fortunately, there’s a vagrant plugin that can detect the IP address assigned to Vagrant. It’s called
vagrant plugin install vagrant-ghost
The other important thing about my setup is that I use the Unix tools that come with Git for Windows. On installation, you have to choose to add the git bin directory to your global path. The most important thing this gives you is bash. I use bash as my main shell (not PowerShell or CMD), so I can’t say whether any of this works from within PowerShell or CMD.
All of the following commands assume you are using bash as your shell. If that is not the case, you will need to translate the commands yourself.
Installing and Running Homestead for HyperV
First you need to initialize the homestead environment. This will clone the repository and run the init script:
git clone https://github.com/johnpbloch/homestead.git Homestead cd Homestead bash init.sh
Then add my vagrant box:
vagrant box add --provider hyperv johnpbloch/homestead
At this point you’ll want to configure
~/.homestead/Homestead.yaml. Open it in your text editor and modify the configuration as necessary. The only setting that you must set a certain way is to change
hyperv. I also bump CPUs to 2 and memory to 2048, but that’s up to you. I also add
type: "smb" to each of the entries in
folders, but that’s not strictly necessary, since SMB is the default option on HyperV.
EDIT (2015-08-31): I no longer override the box used by Homestead, so you’ll also need to add a
box setting to the yaml file and set it to
Now it’s time to run the box. HyperV boxes can only be started with administrative privileges, so you need to open a new shell using Run as Administrator. Navigate to the Homestead directory and run:
Vagrant is going to ask you to enter your user credentials during boot so that it can mount the SMB share points, so be aware of that. The first time it runs, it’ll provision the VM which might take some time.
Hope that helps!
- HyperV is a native virtualization hypervisor for Windows Operating systems. It uses SMB shares by default for mounted directories, which are way faster than VBox shared directories. In general, it blows virtualbox out of the water in terms of performance.
At some point, I’ll need to write about even using it with Vagrant at all. ↩