LaserBeak
LaserBeak

Reputation: 3285

Troubles setting up Homestead dev environment

New to vagrant and just trying to wrap my mind around what's going. Using OSX.

  1. installed Virtual Box

  2. installed Vagrant

  3. Downloaded the homestead Vagrant box via vagrant box add laravel/homestead

    • I presume this is the actual VM image. Where did it download to ?
  4. Cloned the Homestead repository into my 'home' folder. git clone https://github.com/laravel/homestead.git Homestead

  5. created ssh key

-- Possible mistakes made below

  1. Opened homestead.yaml located in the ~/Homestead/src/stubs/

  2. Edited shared folders and mapped nginx directory to domain, mapped IP to mydomain.app in hosts file

  3. Ran vagrant up, vagrant created some huge 2.7GB folder called VirtualToolBox or something along those lines in my home directory, it appeared to have some Virtual machine images in it ? I presume it just copied the Vagrant Box image I downloaded earlier into my home directory ?

  4. I opened the browser and ran mydomain.app and browser stated (no input source file)

  5. I went to fiddle with homestead.yaml file in ~/Homestead/src/stubs/ and updated my shared folders. Next time I ran vagrant up it gave me an error, stating that the old shared folder is no longer there, but I changed the thing in homestead.yaml, but it was still reading the old configuration from somewhere.

  6. Then I found a hidden folder in my home directory, namely .homestead which had yet another homestead.yaml file with the old configuration settings.

  7. I thought I would start fresh. Deleted ~/homestead and ~/.homestead as well that VToolbox folder with vm images folder in my home directory ~/

  8. I have then cloned the Homestead repo again git clone https://github.com/laravel/homestead.git Homestead into my home folder, however when I now run vagrant up I get an error that 'a box must be specified'. running vagrant init or vagrant provision does not help.

Where does that leave me, did I actually delete the whole vagrant VM image I downloaded with vagrant box add laravel/homestead ? And I now need to download it again ? That VirtualToolBox folder that was created is not where it download as it was only created on first vagrant up command. So I hope I don't have to download it again and there's still a copy somewhere ?

Where is the actual image that the vagrant box add laravel/homestead command downloads ?

Where does vagrant install ?

Which homestead.yaml file should I be working with ? The one in the hidden folder ?

What do I need to run after changing configuration/shared folders etc. in homestead.yaml ?

Upvotes: 1

Views: 234

Answers (1)

Frederic Henri
Frederic Henri

Reputation: 53813

Let me try to answer few points from your list of questions, mainly on vagrant box/VM management: vagrant box and the VM are 2 different things.

once downloaded and installed by vagrant, the box will be stored

  • Mac OS x: ~/.vagrant.d/boxes
  • Windows: C:/Users/USERNAME/.vagrant.d/boxes

when you run vagrant up, vagrant creates a Virtual Machine based on the provider you specified (in your case it will be a Virtual Box VM) based on the box you have specified. You can create as many VMs as you want/need from the same box. (Box generally just contains OS and provisionner tool like chef, puppet ... but you can consider it as an image that vagrant is using to create a new instance)

At this stage you have box file used by vagrant (box file under .vagrant.d) and your VM (vbox file for Virtual Box). If you run vagrant destroy it will delete the VM (vbox files) (and also remove the reference from running VM) thats basically what you did manually.

But the box remains intact, so if you run vagrant up again, it will create a brand new VM from the same box that you had downloaded and which is stored under the .vagrand.d folder

Regarding the homestead part:

you have a step missing after #4; once you have cloned the git repo, you should run the following from the Homestead directory

bash init.sh

This will create the Homestead.yaml configuration file located in your ~/.homestead directory

You should then only modify this file and do not touch the files under src/ directory

Upvotes: 4

Related Questions