problems understanding workflow and set up of vagrant and laravel homestead

289 views Asked by At

Up till now I've used a wamp server and thought I'd give Laravel Homestead a try as it's meant to be easier!

I'm having problems getting the set up right and I'm confused about what I'm doing and where I should be doing them.

I've got vagrant and virtual box installed and set up. Windows 7

Normally I have my local files in the same location as the server wamp/www so I created a new folder in this location c:/vagrant to place my development files.

From a CLI from within this directory I followed the instructions on the laravel site (and others), added the homestead box using this command:

'vagrant box add laravel/homestead'

It goes through an install process.

I then used git clone https://github.com/laravel/homestead.git Homestead' to clone the homestead repository. This created a clone as expected inC:/vagrant`

I then ran homestead init which in theory creates a yaml configuration file. My first problem I couldnt find this to check configuration.

Researching further I then discovered that maybe I should be installing this into the root of my user profile. ie c:/users/me rather than the root of the system (excuse the lack of technical knowledge)

So - a few questions: 1. Where should I be running all the commands? From the folder I created or in my user profile? 2. Once installed (if I get that far) where should I place my local development files?

I think I understand that the development files get synced to the virtual machine (set up in the config file)

Sorry, completely new to this approach and not yet getting my head around what I'm trying to do

Thanks

1

There are 1 answers

2
dakine On BEST ANSWER

Are you using cygwin? You should run the commands inside the Homestead folder which is created after you do homestead init. Then you do the configuration or mapping of folders in your Homestead.yaml. it is located in you home directory. in my case in created a .homestead folder. I'm using cygwin btw. There are a lot of youtube tutorials that are very help. that's where i learn how to set up my Homestead environment.

update

I assumed you have installed vagrant and virtual box. then you've downloaded the homestead box. by running this command.

vagrant box add laravel/homestead

you'll know you've download the box when you see it on the list when running this command.

vagrant box list

the output would be something like this.

$ vagrant box list
laravel/homestead (virtualbox, 0.2.5)
lucid32           (virtualbox, 0)

then you need to download the homestead configuration with this command.

git clone https://github.com/laravel/homestead.git Homestead

if your in /directory/projects. You'll have

/directory/projects/Homestead

after downloading the configuration. you need to run this command inside the Homestead folder.

bash init.sh

it will create a hidden homestead folder in you home directory. Inside the .homestead directory you'll find the Homestead.yaml

~/.homestead/Homeastead.yaml 

your Homestead.yaml file would look something like this.

ip: "192.168.1.1"
memory: 2048
cpus: 1
provider: virtualbox

// you need to create this key authorize: ~/.homestead/publickey.pub

keys:
    - ~/.homestead/keys

folders:
    - map: D:\projects\folder -- in your local machine
      to: /var/www  -- map to the folder in your virtual machine

sites:
    - map: myproject.app   --the domain you'll use to access your project in you local machine
      to: /var/www/testproject/public   --the public folder. 

//folders is where you declare your base folder. //site is where you register you application.

hope this make sense to you. Just ignore the rest of the configuration inside your Homestead.yaml file.

lastly you need to edit your hosts file. add this line.

127.0.0.1      myproject.app

you can access you app in your browser on port 8000.

myproject.app:8000

then after you've setup everything. you then go to you Homestead folder.

`/directory/projects/Homestead`

and run

vagrant up

to start the machine.