DEV Community

Cover image for Set up laravel project in a virtual machine with laravel homestead

Set up laravel project in a virtual machine with laravel homestead

safventure profile image Saf Venture Updated on ・4 min read

Buy Me A Coffee

Why Laravel Homestead?

Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. No more worrying about messing up your operating system! That’s why I highly recommended this virtual environment setup.

Before launching your Homestead environment, you must download and install on your pc the ff:

  1. VirtualBox – an application that lets you run an operating system within your operating system. It keeps the data and activity of the operating system inside of it, which is called the guest operating system, separate from your regular operating system, which is called, the host operating system
    Download virtual box here:

  2. Vagrant - tool for working with virtual environments, and in most circumstances, this means working with virtual machines. Vagrant provides a simple and easy to use command-line client for managing these environments, and an interpreter for the text-based definitions of what each environment looks like, called Vagrantfiles. Vagrant is open source, which means that anyone can download it, modify it, and share it freely.
    Download vagrant here:

  3. Homestead – Homestead is a vagrant package that provides a dev environment without the need to install PHP. To install homestead, you need to have a Git installed in your system. If none, download and install Git here:

  4. Composer - tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
    Download composer here:

I like to put my Laravel project in this directory:


In your desired directory, execute the command below:

composer create-project --prefer-dist laravel/laravel Laravel

Now, we have a fresh laravel project in your local machine.

Alt Text

Run the below command thru git bash in your desired directory:
vagrant box add laravel/homestead

You will be prompted to select your choice for

  1. hyperv
  2. parallels
  3. virtualbox
  4. vmare_desktop

Alt Text

Choose number 3 then press enter.

Once laravel/homestead is added successfully for virtualbox, run this command:

git clone Homestead

  • this will clone the homestead repository.

Then execute the ff:


  • this will create the Homestead.yaml file.

Your Homestead.yaml file is inside your Homestead folder. Open it and configure accordingly.
Please see below configuration. I will explain it by section.

Alt Text

The above configuration is all about your IP address, cpus and provider of your VM. You can update it according to your desire but on my part, I’ll leave it as is.

Alt Text

If you are already working with git, you may have an SSH already. But if you don’t have, please run the command below:

ssh-keygen -t rsa -b 4096 -C

This will create a ssh key for you and you don’t need to do anything else.

Alt Text

This is the part where we specify which folders in Windows should be synchronized with the virtual machine. In my case my map is: C:/Users/Dell/Laravel since my Laravel project is in that directory and I want it to mimic in /home/vagrant/Code directory in my virtual machine.

Alt Text

This section will let us map our domain to a folder in our VM. In my case I name my domain as homestead.test then map it to /home/vagrant/code/public in my virtual machine.

Alt Text
This is the summary of my Homestead.yaml

Don’t forget to edit your host file at: C:\Windows\System32\drivers\etc\hosts, then add this at the end of the file:

Alt Text homestead.test

Go to your Homestead directory
Alt Text

cd Homestead

Then run this command:
Alt Text
vagrant up

this will create the environment. If the environment was already created and the up is just resuming a machine or booting it up.

Alt Text
Execute vagrant ssh:

Alt Text

Type cd Code then ll. The Laravel project that we have in our local machine is mimic in our vm.

Alt Text

We can easily access our Laravel project via this address: http://homestead.test.

To shut down the vagrant machine, execute the ff:
Alt Text
vagrant halt

Note: if you change something on your Hometead.yaml, you need to run the command:
vagrant reload –provision

  • vagrant reload --provision will reboot the VM and run the provision steps.

Alt Text
My programming blog begins here, my Home - Laravel Homestead.

Please don't hesitate to leave a comment or ask any question to make this tutorial easily doable as possible to others.

Buy Me A Coffee

Discussion (4)

Editor guide
gerka profile image
German Bidzilja

How is your latency on Windows setup? No matter what conf I try I still got ~7sec load time when I reload the application in the browser. Sometimes managed to get ~2sec, but rather rare.

After some time of playing around I decided to switch to Ubuntu dev environment myself. The latest setup is having Ubuntu on my external SSD. Hook it up to any machine I have at hand, boot it up and continue where I left. Application load latency normal, like on a local dev environment :P

Still curious, how others are experiencing it on Windows and possibly go back some time.

safventure profile image
Saf Venture Author

Hi German,

Thanks for dropping by. Yours is quite fast. Actually in my case, it is way slower because of our internet speed here. I'm not sure if others are experiencing faster latency than yours. :)

gerka profile image
German Bidzilja

I mean latency on the local dev environment, where you are not connected to the outside internet and just launch the application in the browser from your computer. I couldn't get it fast enough on Windows + virtualbox. Was wondering how does it work for you (or anybody who is setting this up on Windows).

Thread Thread
safventure profile image
Saf Venture Author

ohh I see.. On my first launch on my app in the browser, it will take me like around 5 to 7sec. But on my next launch just around 2 sec.