Designinglives

June 23, 2017 at 5:23 pm

Setting up a virtual machine for laravel

What we would need for this to work:
VirtualBox
Vagrant

Both VirtualBox and Vagrant are software packages which will provide us with some easy-to-use installers which can install all popular operating systems. Once installed you can add a laravel/homestead box to you Vagrant install which might take up to 10 minutes to get ready.

vagrant box add laravel/homestead

Once both are installed and the laravel/homestead box has been finished it’s time to clone the homestead repository to the Homestead directory. For this I have made a map called Homestead inside my coding folder called “Laraveljourney”.

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

Next it’s time to do some configuration changes. I’ve done this by going into the Homestead folder and opening up Homestead.yaml with Coda.

coda Homestead.yaml

First you might need to add a SSH key, if you for any reason don’t have one yet or you are not sure you have made one before you can just use this command.

ssh-keygen -t rsa -C "yourname@domain.com"

Next up you should change the following inside your Homestead.yaml file, if you are unsure about which you should change your value to it’s best to look things up inside the Laravel documentation. I have changed both map files, the first one was changed to my Laraveljourney folder (where my Homestead and laravel app are located). The second one I changed to journey.app and the last to, here I changed Code/Laravel to Code/my-app-name.

folders:
    - map: ~/Code
      to: /home/vagrant/Code

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public

To finish and startup the vagrant server you need to use the following command.

vagrant up

This will make the vagrant machine startup running the application given inside your Homestead.yaml file. If you would now edit your hosts file by adding the following you would be able to use journey.app as a domain name to test your current application on.

192.168.10.10  journey.app
0 likes homestead , vagrant , virtual machine
Share: / / /