Laravel Homestead provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. Laravel Homestead is an official, pre-packaged Vagrant box. Vagrant is a tool for building and managing virtual machine environments in a single workflow and provides a simple, elegant way to manage and provision Virtual machine.
Homestead runs on any Windows, Mac or Linux system and includes:
And include all other software you need to develop amazing Laravel applications.
Before running the Homestead environment in your machine, first, you must install VirtualBox6.x, VMware, Parallels or Hyper-v. You must download and install any of this software. So in this article, I have installed the VirtualBox6.x. You can download VirtualBox6.x from this link: https://www.virtualbox.org/wiki/Downloads.
After installation of VirtualBox6.x or any of this software, you must install Vagrant. You can download vagrant from link: https://www.vagrantup.com/downloads.html
Once VirtualBox6.x and Vagrant have been installed, you should add “laravel/homestead” box to your Vagrant installation using the following command in your terminal:
i. Run this command: “vagrant box add laravel/homestead”
Running this command in your terminal, it will take few times to install homestead in your vagrant box which depends on your internet connection speed.
ii. Run this command: git clone https://github.com/laravel/homestead.git ~/Homestead.
After installing Homestead in vagrant box, then you should have install Homestead by cloning the repository onto your machine
iii. Run this command: “cd ~/Homestead”
And then type the command “bash init.sh”
This “bash init.sh” command will create the Homestead.yaml configuration file.
IV. Creating SSH key and run the command. After run this command, simply press the enter button whatever command line asks you.
ssh-keygen –t rsa –C “firstname.lastname@example.org”
Next, you should edit the “Homestead.yaml” file included in the repository. In this file, you can configure the path to your public SSH key, as well as the folders you wish to be shared between your main machine and the Homestead virtual machine.
Let’s edit our “Homestead.yaml” configuration file which we generated. Directory of this file is located at: “C:\Users\USER_NAME\Homested”.
The folders property of the Homestead.yaml file lists all of the folders you wish to share with your Homestead environment.
And the sites property of the Homestead.yaml file allows you to easily map a “domain” to a folder on your Homestead environment.
After configuring the “Homestead.yaml” file, you have to edit the “hosts” file, which is located at directory “C:\Windows\System32\drivers\etc”. And add the address (192.168.10.10 homestead.test) at the end of your host file.
Once you have edited the Homestead.yaml, run the “vagrant up” command from your Homestead directory. This will boot the virtual machine and automatically configure your shared folders and Nginx sites.
After the “vagrant up” command, use the “vagrant ssh” command. This will login to you with your virtual machine.
Let’s create our first Laravel project through homestead. Type the command “composer create-project –prefer-dist laravel/laravel test”. It will create new Laravel project in a folder name test.
Installation of laravel project
Enter “homestead.test” from your browser and make sure homestead is running. You will see welcome page now.
Tags: Laravel Homestead