Step by step guide to install Laravel including Homestead:
- Download Composer
- Download (the installer) and install Laravel using the following command in Terminal:
composer global require "laravel/installer"
- Download VirtualBox, then double-click the package to install it
- Download Vagrant, then double-click the package to install it
- Add the Vagrant box to Laravel using the following command in Terminal:
vagrant box add laravel/homestead
- Make sure to pick choice 3 (which stands for the VirtualBox provider) when asked
- Clone the Homestead GIT repository using the following command in Terminal:
git clone https://github.com/laravel/homestead.git ~/Homestead
- Change to the Homestead directory using the following command in Terminal:
cd ~/Homestead
- Check out the latest Homestead GIT repository using the following command in Terminal:
git checkout v7.17.0
Note: Make sure to pick the latest stable Homestead GIT repository version here
- Terminal:
bash init.sh
Note: This will generate the initial Homestead.yaml file in the Homestead install directory, which I’ll explain in more details below
Homestead.yaml
The Homestead.yaml comes with default settings. The most important changes I make are folders, sites, and databases.
Folders
folders: - map: path/to/your/host-os/directory to: path/to/your/guest-os/directory
The host-os directory is where your project’s files will be stored. Here’s a real-life example:
folders: - map: /Applications/MAMP/htdocs/vagrant/code/project1 to: /home/vagrant/code/project1
Sites
sites: - map: project1.dev to: /home/vagrant/code/project1/public
You must also edit your local host file, using the following Terminal command:
sudo nano /etc/hosts
For example:
192.168.10.10 project1.dev # The IP should be the same as set in the Homestead.yaml configuration file.
When ready use the following Terminal command:
vagrant up
Or in case of an edit use the following Terminal command:
vagrant reload --provision
Troubleshooting Homestead
If you have a headache to get Homestead running as it should, perhaps because of the “No input file specified.” message like I have experienced, here comes the solution:
- folders: map is the actual location of your files, locally
- folders: to is the location on your virtual machine
- sites: map is the name of your project (this is a dummy domain, don’t forget to edit your hosts file)
- sites: to is the location where your files are hosted on your virtual machine (comparable to the location on a remote server)