Install Laravel Homestead
Laravel is one of the most powerful PHP Framework nowadays, it will save your time and effort to make a web application. Laravel has shaken up the PHP community in a big way – especially when you consider that version
5.2 of Laravel. Using Laravel, you can build and maintain high quality web applications with minimal fuss.
Of course Laravel offical has its own document to guide you how to install, but it seems not really easy to follow due to lack of some steps, maybe because you must collect from 4.2 to 5.2, so this article will help you focus on the latest version 5.2
Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server or any other server software on your local machine. No more worrying about messing up your operating system. Vagrant boxes are completely disposable if something goes wrong, you can destroy and re-create the box in minutes!
Homestead runs on any Windows, Mac, or Linux system, and includes the Nginx web server, PHP 7.0, MySQL, Postgres, Redis, Memcached, Node, and all of the other goodies you need to develop amazing Laravel applications.
If you are using Windows, you may need to enable hardware virtualization (VT-x). It can usually be enabled via your BIOS.
- Ubuntu 14.04
- PHP 7.0
- Node (With PM2, Bower, Grunt, and Gulp)
How to install Laravel Homestead (5.2)
This article will show you how to install Laravel Homestead step by step
Step 1: Install pre-requisites
Before launching your Homestead environment, you must install VirtualBox 5.x or VMWare as well as Vagrant. All of these software packages provide easy-to-use visual installers for all popular operating systems.
If you want to use VMware provider, you will have to purchase both VMware Fusion/Workstation and the VMware Vagrant plug-in. Because it is not fee, We recommend you use vagrant box instead.
You also need to install Composer a 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.
Step 2: Clone the Homestead
Let’s go to any folder you want to store your code then run the command below by Git bash or command terminal
git clone https://github.com/laravel/homestead.git Homestead
This command will clone Homestead to your local machine, after this step you will see the folder
Homestead, let’s go inside folder.
Step 3: Adding the Vagrant Box
Once VirtualBox and Vagrant have been installed, you should add the laravel/homestead box to your Vagrant installation using the following command in your terminal. It will take a few minutes to download the box, depending on your Internet connection speed.
vagrant box add laravel/homestead
Step 4: Configure Homestead
Homestead folder, open your src/stubs/Homestead.yaml file
--- ip: "192.168.10.10" memory: 2048 cpus: 1 provider: virtualbox # if you want to add local box that you downloaded to you local machine, just add here then remove the # sign #box: ./vagrant_box/Laravel5_2.box # but you need to remove or comment the line that define box version in Homestead/scripts/homestead.rb file #config.vm.box_version = settings["version"] ||= ">= 0.4.0" # you can name your box to whatever you want #name: "homestead72" authorize: ~/.ssh/id_rsa.pub keys: - ~/.ssh/id_rsa # you need to create folder Code inside Homestead folder, this is the shared folder folders: - map: ./Code to: /home/vagrant/Code # we will create homestead52.local with composer to build a new laravel project, this used to configure your Nginx sitess. sites: - map: homestead52.local to: /home/vagrant/Code/homestead52.local/public databases: - homestead52 # blackfire: # - id: foo # token: bar # client-id: foo # client-token: bar # ports: # - send: 50000 # to: 5000 # - send: 7777 # to: 777 # protocol: udp
Step 5: Set Your SSH Key
Don’t have an SSH key? On Mac and Linux, you can generally create an SSH key pair using the following command:
ssh-keygen -t rsa -C "you@homestead"
Step 6: Init Homestead.yaml
bash init.sh command to create the Homestead.yaml configuration file, the Homestead.yaml file you edit above will be placed in the
Step 7: Launch the vagrant box
Vagrant will boot the virtual machine, and configure your shared folders and Nginx sites automatically! To understand more about vagrant you can go to vagrant page
Step 8: Add the domains for your Nginx site to the
The hosts file will redirect your requests for the local domains into your Homestead environment. On Mac and Linux, this file is located at
/etc/hosts. On Windows, it is located at
C:\Windows\System32\drivers\etc\hosts. The lines you add to this file will look like the following:
Make sure the IP address listed is the one you set in your Homestead.yaml file. Once you have added the domain to your hosts file, you can access the site via your web browser!
Step 9: Create the laravel project
Go to the Code directory you created above, run this command
composer create-project laravel/laravel homestead52.local
This command will load all dependency library that need to Laravel 5.2 then after this step is completed, you can open browser and type
http://homestead52.local you will see the blank page with the text “Laravel 5“.
Those above 9 steps are what you need to install Laravel homestead, you can install as much as project as you want in the same environment by adding the corresponding site domain and map folder in
step 4 then repeat the step 8 & 9. We hope this is helpful for you. Happy coding with Laravel.