Back

My Homestead 2 setup on Windows


I created this thread as a reply to another to keep the topics separate but related.

Here is how I setup my Homestead 2 without installing php or composer on the windows machine.

I'm using Windows 7.

On my system I have the folder path like so:

c:\local_devel\Code
-- this will be mounted on the virtual machine as my code directory

c:\local_devel\Homestead1
-- this is my old homestead box version 1

c:\local_devel\Homestead2
-- this is my new homestead 2 box

c:\local_devel\VirtualMachines
- default VirtualMachine location in Virtual Box, I moved my default create directory - you don't have to do that.

Download the Homestead 2 package from GitHub, https://github.com/laravel/homestead/archive/master.zip

Inside the zip is a folder homestead-master, pulled that out and rename it to the Homestead2 at the path c:\local_devel\Homestead2

Now a few things need to be adjusted.

In the folder c:\local_devel\Homestead2 I created a new folder called .homestead

Copy the contents of src\stubs to that folder.

If you have a existing homestead.yaml you should be able to use it instead instead, just put it in the new .homestead folder (add in databases if you want them created). I think the only new thing is the database section.

Put in any customizations to the file for example I use a plugin (vagrant-hostsupdater) to update my hosts file, it allows you to add in a aliases config key to the yaml file a lot eaiser than editing by hand.

If you use that you will need to update the c:\local_devel\Homestead2\scripts\homestead.rb and add this line, config.hostsupdater.aliases = settings["aliases"] after the network on line 10-ish

(Be careful of tabs, vagrant does not like tabs in the yaml file, it will error with something about invalid characters)

You could delete the src folder if you want, it's not used in this setup at all - after copying the files out of stubs.

Edit c:\local_devel\Homestead2\Vagrantfile and change theses paths:

homesteadYamlPath = File.expand_path("~/.homestead/Homestead.yaml")
afterScriptPath = File.expand_path("~/.homestead/after.sh")
aliasesPath = File.expand_path("~/.homestead/aliases")

to 

homesteadYamlPath = File.expand_path(".homestead/Homestead.yaml")
afterScriptPath = File.expand_path(".homestead/after.sh")
aliasesPath = File.expand_path(".homestead/aliases")

Thats it. No install of php or composer on the base machine.

You should now be able to do a "vagrant up" in the c:\local_devel\Homestead2 folder to start up the instance, and "vagrant halt" to shutdown.

Next ssh (I use putty) in like normal and customize it however. I've set up a shutdown script to dump a backup of my databases. I also use vagrant-vbguest to install the virtual box guest addition.

One cavaot, I noticed this version creates one virtual box named Homestead. I've not tested if I can create a second folder and it not overwrite the previous virtualbox instance. I have not gone futher to put back in the random-string addon to the name so that I can have multiple homestead instances if I want.

Any questions, ask away.

wgmv replied 2 years ago

Hi thanks for the tips, very helpful for me! Especially the hostsupdater plugin.

I'd like to add that instead of editing the Vagrantfile I moved the .homestead directory to C:\Users\ME\ .homestead which seems to work as well (on Win 8.1) and might be even easier.

MindisWorld replied 2 years ago

TerrePorter,

THANK YOU REALLY MUCH!!! 3 months ago or so I wasted like 10 hours of searching how to make it work on Windows this Homestead, which as stated on laravel website "should be fast and easy to set up", however I gave up with no luck. But now with your message I made it to work.

peterbata replied 2 years ago

I was wondering if you would be so kind to share your Homestead.yaml and VirtualBox network settings with us. Specifically the IP settings. I seem to be having some trouble in this area. It would be greatly appreciated. Thank you for sharing your time and experience with the community. Peter

TerrePorter replied 2 years ago

Sorry I missed the previous replies.

wgmv: I got tired of editing the hosts files by hand, so the plugin really helps.

MindisWorld: Glad it worked for you, in my opinion the last version was a lot easier to setup. Especially since they now want php and composer on the host machine, not something I want personally.

peterbata: Here is the Homestead.yaml file. I've upped the CPUs from 1 to 3 as I have an 8 core cpu so figured why not. The aliases is used by the hostsupdater plugin, mentioned above. I have about 4 or so more sites configured but I shortened it a bit to post here, no point for that many repeats. It's not much different from the default, https://github.com/laravel/homestead/blob/master/src/stubs/Homestead.yaml You could add the databases to have them created when provisioning, just as easy ssh in and create it when adding in a new site.

---
ip: "192.168.10.10"
memory: 2048
cpus: 3

authorize: C:\Users\tporter\.ssh\id_rsa.pub

keys:
    - C:\Users\tporter\.ssh\id_rsa

aliases: ["dev1.lan", "dev2.lan", "dev3.lan", "dev4.lan", "phptesting.lan"]

folders:
    - map: C:\local_devel\Code
      to: /home/vagrant/Code

sites:
    - map: dev1.lan
      to: /home/vagrant/Code/dev1/public
    - map: dev2.lan
      to: /home/vagrant/Code/dev2/public    
    - map: dev3.lan
      to: /home/vagrant/Code/dev3/public    
    - map: dev4.lan
      to: /home/vagrant/Code/dev4/public    
    - map: phptesting.lan
      to: /home/vagrant/Code/phptesting/public

databases:
    - homestead

variables:
    - key: APP_ENV
      value: local

Nothing customized on the network settings, its the vagrant defaults - not sure what info to provide. What trouble are you having with the network ?

TerrePorter replied 2 years ago

TerrePorter said:

One cavaot, I noticed this version creates one virtual box named Homestead. I've not tested if I can create a second folder and it not overwrite the previous virtualbox instance. I have not gone futher to put back in the random-string addon to the name so that I can have multiple homestead instances if I want.

A small update to this, you can change the VM name in the scripts\homestead.rb file, around line 15

vb.name = 'homestead'

This is the name of the virtual machine to be used.

I've updated my file to allow me to specify a name in the .homestead\homestead.yaml file

vb.name = settings["vmname"] ||= "homestead"

then in the yaml file,

vmname: homestead-hvmmtest
Metalogic999 replied 2 years ago

"In the folder c:\local_devel\Homestead2 I created a new folder called .homestead"

Windows 8.1 won't let me create a folder called .homestead - I don't think it likes the leading "." - it just says "you must type a filename" - any suggestions? Thanks

TerrePorter replied 2 years ago

You can change the name of the .homestead, on my laptop which is running 8.1 it is just homestead.

You will need to update the vagrantfile and remove the dot from .homestead, or you can name it something else as long as it matches the folder name where the files are.

jammygit replied 1 year ago

Registered to add - if you're on Windows and want to create a folder with the name ".homestead" (for example), then enter ".homestead." - dot at the begining AND the end - Explorer will removing the trailing dot, but it's necessary to stop Windows complaining.


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us