I am going to write down a step-by-step procedure to set up the Homestead for Laravel-5.2 in Windows 10 with VirtualBox. I spent a lot of time to set up the homestead for Laravel-5.2 in my windows 10 PC. I am writing this so that anybody could get benefit from this post. Well, enough talking. Let’s dig in.

The official documentation for Laravel Homestead setup is: Official Documentation.

N.B: Please try to type all the commands instead of copy-paste from this tutorial. It may cause unexpected errors. See the response section below for more information.

Step 1

As the official documentation says, you need to enable hardware virtualization (VT-x). To do this, follow this site: http://www.howtogeek.com/213795/how-to-enable-intel-vt-x-in-your-computers-bios-or-uefi-firmware/.

If this doesn’t help, then Google it with your laptop model number or with your PC configuration. You must enable hardware virtualization (VT-x). And If you are using Hyper-V on a UEFI system, you additionally need to disable Hyper-V in order to access VT-x.

You may also like:
The Eight Biggest Laravel Development Mistakes You Can Easily Avoid.

Step 2

Now, you need to download the latest version of VirtualBox and vagrant. 

After downloading these, first, install VirtualBox. And then install Vagrant. You may need to restart your PC after the installation complete.

Step 3

Now, we need to install git bash (if git bash is already installed in your PC, then skip this step). Download link: https://git-scm.com/download/win. After downloading, install it.

Step 4

Now, open git bash in administrator mode and run the following command:

If you are now getting an error like this:

Then, download this MS Visual C++ 2010 x86 Redistributables and install it. Now, run the following command again:

It should add the Laravel/Homestead box to your Vagrant installation. It will take a few minutes to download the box, depending on your Internet connection speed.

Step 5

After completing Step 4, type cd ~ on you git bash and hit enter. Now run the following command:

It will clone the Homestead repository into a Homestead folder within your home (C:UsersUSER_NAME) directory.

Now, run the following two commands one-by-one:

This will create the Homestead.yaml configuration file. The Homestead.yaml file will be placed in the C:UsersUSER_NAME.homestead directory.

NB: (According to this #06b52c7 change, from Feb 17, 2017, the Homestead.yaml file will be now located in C:UsersUSER_NAMEHomestead folder)

Step 6

Now, we need an ssh key. To check it is already exists in your computer or not go to C:UsersUSER_NAME directory and try to find out a folder named .ssh. If it exists, go into the folder and try to find out two files named id_rsa and id_rsa.pub. If the folder .ssh doesn’t exist or the folder exists but the two files named id_rsa and id_rsa.pub doesn’t exist then run the following command:

Then, the command prompt will ask you two things. You don’t need to type anything, just press enter to whatever the command prompt asks you. After finishing this command, a new .ssh folder (if already not exist) will be created with the two files named, id_rsa and id_rsa.pub, inside it.


Step 7 

Now, we are going to edit the Homestead.yaml file, which is generated in Step 5. This step is very important. Go to the C:UsersUSER_NAME.homestead directory. There, open the Homestead.yaml file with any text editor. The file will look like this:

I will explain the file step-by-step and also modify it to configure our Homestead. Let’s start.

These lines specify on which IP address our Homestead will listen (in this case 192.168.10.10), 
the maximum amount of memory it can consume (2048), how many CPUs it will use (1), and the provider (VirtualBox). 


In these lines, we are going to set up our ssh keys for Homestead. Remember we have created our ssh keys in step 6. We are going to point to those two files in our Homestead.yaml file. After editing these two lines, it will look like this:

Don’t forget to use the lowercase of your drive name (“c” instead of “C”) and forward-slash(“/”) instead of backslash(“”). See what I have written. In a natural way, we should write C:UsersUSER_NAME .ssh, right? but no, see carefully. I have written c:/Users/USER_NAME/.ssh instead of C:UsersUSER_NAME.ssh. This is the tricky part; don’t miss it. 

We will always use the lowercase of our drive name (like “c” instead of “C”) and the forward-slash(“/”) instead of backslash (“”) in our Homestead.yaml file.


Here, we are going to map a folder, which will be used by both our PC and Vagrant. just imagine a common folder where if we change anything from our Windows 10 PC, the change will be visible from vagrant (and vice versa). 

– map: ~/Code means the folder that is located in our PC and to: /home/vagrant/Code means where we will access the same folder in vagrant. Not clear yet? Well just see the lines after I change them. It will be clear after change:

See now? my PC’s e:/Homestead_Projects folder and vagrant’s /home/vagrant/Code folder are pointing to the same folder. If you change anything in /home/vagrant/Code folder, it will be reflected in the e:/Homestead_Projects folder also and vice versa. 

In my case, e:/Homestead_Projects is my project folder. In your case, use your own project folder. You can use any folder name here like /home/vagrant/ANY_FOLDER_NAME instead of /home/vagrant/Code


Don’t get confused about this one with the last discussion. these lines have nothing to do with the last discussion. I am going to explain it. This configuration says that if we hit homestead.app from our browser, the vagrant will serve the site from /home/vagrant/Code/Laravel/public folder.

Yes, I know we have not created any folder named Laravel in our /home/vagrant/Code folder from Vagrant or in our e:/Homestead_Projects folder from our PC yet. We will create it later. You will find your answer in step 10. In the future, if you develop more sites, then this configuration will look like this:

One more thing — the prefix of /Laravel/public, which is /home/vagrant/Code has to be the exact match of to: /home/vagrant/Code from the last section. If you have used /home/vagrant/ANY_FOLDER_NAME to map your PC’s project folder, then here, you have to use /home/vagrant/ANY_FOLDER_NAME as the prefix of /Laravel/public, which will look like /home/vagrant/ANY_FOLDER_NAME/Laravel/publicTHIS IS IMPORTANT.

Please read “
N.B.” part of step 8 before proceed to next para.


This line will create a database in Vagrant named homestead.


After editing my Homestead.yaml file, it looks like the following:

Step 8

Now, Windows will not allow the homestead.app link to be hit from the browser. We have to add this to the windows hosts file. so that if we hit homestead.app from our browser, it will go to the IP address we defined in our Homestead.yaml file. For now, our defined IP address is 192.168.10.10.

Go to C:WindowsSystem32driversetc folder and edit the hosts file in any text editor (text editor must have to open in administrator mode). Add the following line at the very bottom of the hosts file:

If you want to add another site, it just append here like this:

Now, homestead.app is accessible from our browser. but don’t hit it yet.

N.B:  https://laravel-news.com/chrome-63-now-forces-dev-domains-https 

this link says “Based on this article by Danny Wahl, he recommends you use one of the following: “.localhost”, “.invalid”, “.test”, or “.example”.  So, you should use “homestead.test” or something else instead of “homestead.app” 

Nowadays browser forces all .dev domains to use HTTPS. You can try this. Or you can use one of the following: “.localhost”, “.invalid”, “.test”, or “.example”. 

If all this sounds like too much trouble another viable option is to switch to Firefox as your development browser.

Step 9

Now, we can start our Homestead using Vagrant by running the command vagrant up. But, to do so, we have to always run this command from C:UserUSER_NAMEHomestead directory. We can do something so that we can run vagrant boxes from anywhere using git bash.

To do so, download this file https://www.dropbox.com/s/haekwwhab4jn56r/.bash_profile?dl=0 and paste it in C:UserUSER_NAME directory or in C:UserUSER_NAME directory and create a file named .bash_profile. Then, write down the following lines in the .bash_profile file:

Now, using git bash from anywhere by running the homestead up command, you can run the vagrant box. To terminate, vagrant box run the homestead halt command. You might have to restart Git bash since the .bash_profile is loaded upon start. For the first time, homestead up will take some time.

I am writing down the two commands again:

  • NB:
    1. If you are getting bash: cd: /c/Users/User Name/Homestead: No such file or directory” this kind of error then please replace the following line of .bash_profile cd ~/Homestead && vagrant $*   with 
      cd “YOUR_ACTUAL_HOMESTEAD_DERECTORY_PATH” && vagrant $* and of course restart git bash.
    2. If these command doesn’t work on git bash then please try to run these commands from CMD from now on.

Step 10

Now, we are going to create our first project named, Laravel. Your questions from seeing /home/vagrant/Code/Laravel/public in Step 7 will be clear now. Until now, we only have the /home/vagrant/Code folder. There is no folder named Laravel in the /home/vagrant/Code folder yet.

You can check your project folder on your PC that I am telling you right or wrong. In my case, the project folder on my PC is e:/Homestead_Projects. You will see that there is no folder named Laravel in your PC’s project folder. Well, we are now going to create it.

Run Homestead by using the homestead up  command. Then, run the following command:

This will log in you into Vagrant. Type ls and press enter. You will see there is only one folder named Code. Type cd Code and press enter. Now, you are in the Code folder. Type ls and press enter again, and you will see that there is nothing in this folder yet.

Now, it’s time to create our first laravel project here. Run the following command:

This command will take some time and create a laravel project in the Laravel folder. Type ls and press enter. Now, you will see there is a folder named Laravel. Go to your project folder in your PC (in my case, e:/Homestead_Projects), and you will see that there is a folder named Laravel. Now you can see that the /home/vagrant/Code folder and your project folder are actually the same folder.

Step 11

Well, everything is set now. Make sure the homestead is running. Now type homestead.app in your browser and press enter. You should see the Laravel 5 welcome page now 🙂

Congratulations! Please share this article and leave a comment for any questions or feedback. 

Further Reading



Source link

Write A Comment