June 23, 2017 at 5:23 pm

Setting up a virtual machine for laravel

What we would need for this to work:

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 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 ""

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 and the last to, here I changed Code/Laravel to Code/my-app-name.

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

    - map:
      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 as a domain name to test your current application on.
0 likes homestead , vagrant , virtual machine
Share: / / /