How I setup Vagrant + Homestead on Windows 10

Ok, I will try to make it simple and fast, I might not have all the links right now ready but I will try hard to give as much info as I can.

For the past few month I had tried to setup my windows laptop as a development machine, and trust me I always failed to make it work nicely with Vagrant and Homestead or any Vagrant box for PHP development.

The problem was not the boxes, but in other issues, like the fact that windows does not have real Terminal (yes CMD is not a real terminal), and that it wont come with everything you need, so here is how I did it (cause today was a success story for me) .

Last Friday my lovely wife (Hala) helped me to upgrade my HDD to SSD, and yes I don’t like to play with hardware thats why she did it for me :D, and since I have upgraded my windows to version 10 Pro (thanks for the free upgrade Microsoft), I did a fresh install and it worked like a charm .

So just remember everything am doing here was on a fresh windows 10.

I followed Josh Lockhart post to install everything, but his post was talking about using the built in php server, which is something I don’t use in my daily job, and it wont work with you if you are developing a project which depend on sub-domains, or at least thats what I know it wont work directly, so you can follow his post to install everything you need locally but as I said he dont talk about Vagrant/Homestead so let me tell you what I have did :

1- Installing Vagrant 1.8.1 on windows, after installing Virtualbox 5.x :

The first issue you will face is that you cant add any box to vagrant, and each time it will give you an error like this one

Screenshot on 1.9.2016 at 3.07.44 PM

So after searching on google and many other resources, I found that you will have to replace the embeded curl.exe file which comes with Vagrant with another curl.exe file downloaded from the main curl website ( 7.46 )  for windows 64bit, after that you go to C:\HashiCorp\Vagrant\embedded\bin and replace it.

Side note : its better if you just make a backup for curl.exe which comes with Vagrant before you replace it.

After that you will be able to add laravel/homestead successfully to vagrant.

2- Virtualization issue :

Another issue that I have found is that if you have installed Hyper-V tools on windows, virtualbox will fail to boot your vagrant box and you will stuck at the SSH-Auth process then it will time out, I solved this issue by un-installing Hyper-V tools and also I have installed CygWin openSSL package , not sure why I install it, but a video on youtube suggest it and I though to myself why not, cause at the end Vagrant really need to deal with SSL.

This will make everything work for you, now I have few other thing which I like to do on any windows I own, which is installing gnu/*nix utility on it, cause you know its windows ;) , so you can install Gow ( Unix command line utilities installer for Windows. ) , which will install everything you used to use, but it also will cause a small problem with Vagrant.

Vagrant ssh , uses Openssh to access the box, but Gow will install putty, so Vagrant ssh wont work with you any more, and to solve this issue you can do the following, make sure you go to the bin directory of Gow, then rename ssh.bat to ssh, now if you dont have ssh installed on your computer, try ssh -v and it didnt work go to openSSH for windows website, download the installer and install the Client only, no need for the server, and now your vagrant ssh will work like a charm.

If you are as Lazy as I am you still need another app called Host File Editor which will give you the ability to edit windows hosts file with a nice GUI

Screenshot on 1.10.2016 at 1.16.32 PM

Filed under: Code, Laravel, PHP