Provide 4 You
How to Install Homestead 5.2 and Laravel on Windows 10 - Printable Version

+- Provide 4 You (http://provide4you.com)
+-- Forum: Tricks (http://provide4you.com/forumdisplay.php?fid=5)
+--- Forum: Other Tricks (http://provide4you.com/forumdisplay.php?fid=19)
+--- Thread: How to Install Homestead 5.2 and Laravel on Windows 10 (/showthread.php?tid=16)



How to Install Homestead 5.2 and Laravel on Windows 10 - shubhamverma - 05-12-2017

[Image: tEefhM8.jpg]

Last night, I got to ‘refresh’ my Windows 10 PC due to some graphic glitch which prohibit me from resuming my Windows.
And now, I have to reinstall and reconfigure my Laravel working environment on this PC and I think I could spend some time to make a quick note in this blog so you guys can replicate my steps if you wish to do so ?

1. Download

First, you have to download

  1. Latest Virtualbox for Windows host
  2. Latest Vagrant for Windows
  3. Composer for Windows
  4. Git for Windows
  5. Any advance text editor like Brackets, SublimeText 3 or even Notepad++
  6. PHP (no need if you already have XAMPP or WAMPP in your Windows)
We need VirtualBox to run virtual server (the vagrant-homestead)
We need Vagrant, to bridge our development environment (Windows 10) and virtual server (Linux Ubuntu in VirtualBox)
We need composer to download and install Homestead into Vagrant
We need Git for its Git Bash
We need advanced text editor to edit homestead.yaml file (to configure our homestead machine and provisioning)
We need php because Composer requires it. If you have XAMPP or WAMP in  your Windows, you don’t need to download PHP.
We need MobaXTerm because Git Bash suck when we SSHing our virtual server. And I don’t like Putty because its output is not color coded (feel free to use your Putty or any favorite CLI for SSHing of yours)

2. Install


Once everything is downloaded, please install them with respect to this sequence.

SublimeText 3



Install any advanced text editor (if you don’t have any). I recommend SublimeText 3 or Brackets. (Try to install package manager + material theme. You may love it)

Oracle VirtualBox


Install VirtualBox (restart if needed).
 
Vagrant

Install Vagrant (restart if needed). Vagrant need VirtualBox, so don’t install Vagrant before you install VirtualBox.
 
Git SCM

Install Git as usual. But pay attention on 2 screens and choose the option as below:



Use Git from the Windows Command Prompt

Checkout as-is, commit Unix-Style line endings

 
PHP

Note: You may skip this step if you have XAMPP or WAMPP install.


Extract PHP to your C: drive, so your PHP installation folder located at C:/php
Open C:/php
Duplicate (copy paste) php.ini-development
Rename php – Copy.ini-development to be php.ini
Open php.ini using text editor
Uncomment


Code:
extension_dir = "ext"
extension=php_mbstring.dll
extension=php_openssl.dll



Install Composer

Install composer as usual. When it asks the location of php.exe file,
Browse to php.exe location (like C:\php\php.exe or C:\Xampp\php\php.exe)
If composer does complains missing MSVCR110.DLL, download Visual C++ Redistributable and install both (32bit and 64bit if your computer is 64bit Windows)

Install Homestead on Vagrant


Homestead is a package or box consists of:


By adding homestead in Vagrant (VirtualBox), we will have a complete Linux virtual server with all the above services and features.

To download a homestead box, open Git Bash and type


Code:
vagrant box add laravel/homestead

If this command fails, make sure your Vagrant installation is up to date and you install Microsoft Visual C++ 2010 Redistributable Package (x86) (especially if you are using Windows 10)

Once complete, type the command below.


Code:
cd ~

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

Depending on your internet connection, the cloning step may takes a few minutes. Then, the command below to initialize homestead.


Code:
cd

cd Homestead

bash init.sh

3. Configure

After everything is installed correctly, we need to configure a few stuff.

Install and Configure Homestead Virtual Server Setup

Close and re-open Git Bash (important)

Code:
cd

cd .homestead

explorer .

Edit file homestead.yaml using your preferred text editor (like SublimeText or Brackets) like so.
Let say we want Homestead to work like this:

  1. Our source code project will be stored in C:/Projects
  2. Our first project will be named as myProject.dev
  3. This project will use a database which is named as myProject.dev as well
So, change this part like so

Code:
folders:
   - map: C:/Projects
     to: /home/vagrant/Projects

sites:
   - map: myProject.dev
     to: /home/vagrant/Projects/myProject.dev/public

databases:
   - myProject.dev

Save the file and close the text editor.

On the git bash, we need to generate our SSH Key. Type the code below (dont forget to change it to your actual email address.

Code:
cd

ssh-keygen -t rsa -C "youremail@vendor.com"

Press enter 3 times to complete it.

Finally, create the project folder by typing the command below


Code:
cd C:
mkdir Projects

Or you can create a folder name Projects in C drive using Windows Explorer (your choice buddy)

Custom Domain Name.

We plan to access our project from our browser using myproject.dev URI.

We are not encouraged to access our project using the virtual server IP address because many projects reside on that server and use the same IP address. Vagrant has done a great job that enable us to use domain name for each project instead of using IP address.

So, we have to edit our hosts file in order to do so.
Using Windows Explorer, go to C:\Windows\System32\drivers\etc
Copy the hosts file to the desktop and edit its content like so


Code:
192.168.10.10    myproject.dev



Save it and copy it back to C:\Windows\System32\drivers\etc (You need administrator access to complete this job)

4. Use


Now we can fire up our virtual server and deploy our Laravel project.

Start Homestead

To start a homestead virtual server, using the git bash, type the code below


Code:
cd

cd Homestead

vagrant up



Whenever Oracle VirtualBox requires permission, grant it.

Troubleshooting

  1. Make sure your BIOS turn on VT-x (Intel) or AMD-V
  2. If VT-x or AMD-V is turned on in BIOS but your VirtualBox can’t see it… chance are your Hyper-V is turn on. Disable it at Control Panel\Programs\Programs and Features\Turn Windows features on and off.
  3. Sometime, it is easier to troubleshoot if you run VirtualBox and see whats happening behind the scene (the vagrant will create a virtual machine, name it homestead and fire it up). It could give you better idea what cause your homestead can’t be fire up.
  4. Sometime, when your computer is not fast enough, Vagrant time out. Please run again.
  5. Sometime, you may want to delete your homestead and create it again using ‘vagrant destroy’
Speed Up

If you use VirtualBox 5 (and above), you could speed up your virtual machine by setting it acceleration

Right click on homestead (in virtualbox window), click settings
Then click on System -> Acceleration tab –> Paravirtualization Interface : KVM

Entering the Virtual Server

Using Putty or MobaXTerm

Using MobaXTerm, create a SSH session to
  • 192.168.10.10
  • username: vagrant
When it ask for password, type vagrant as password.

Using Git Bash



In Git bash, just type


Code:
cd

cd Homestead

vagrant ssh

Deploy Laravel Project

Using GitBash (in Windows), type the command below


Code:
composer global require "laravel/installer"

Global Path for Composer Binaries

We need to add this path into Windows system path:

C:\Users\YOURNAME\AppData\Roaming\Composer\vendor\bin

PS: AppData is hidden folder. Need to show hidden file first.


To do so, open

  1. Control Panel -> System and Security -> System -> Advanced system settings
  2. A system properties window will showed. On Advanced tab, click on Environment Variables… button
  3. Under System variables section, click on Path and click on Edit… button.
  4. Type a semi-colon (Wink followed by the above path.
  5. Click OK and done.


CLOSE ALL GIT BASH WINDOWS or COMMAND PROMPT WINDOWS in order to refresh system path.


Code:
cd c:

cd Projects

laravel new myProject.dev

Happy Laraveling.

Note: Feel free to ask in the comment section below.




tages : Composer, Homestead, Laravel, Vagrant, Windows 10, install homestead on windows 10, install laravel on live server, install homestead laravel on windows, install laravel 5 homestead on windows