Set up Laravel Homestead Development environment
Install PHP 7 and composer
This article assumes you have PHP 7 and composer installed. If not, you can install PHP7 via brew if you are on Mac and install composer globally by downloading composer.phar
brew update
brew install php@7.2
mv composer.phar /usr/local/bin/composer
Install virtual box and vagrant
You need to install virtual box and vagrant
Add vagrant box
When you add vagrant box, the version is quite important. I have experienced different kinds of errors just because of different version numbers. I have tested laravel/homestead 9.3.0 working ok with PHP 7.2
vagrant box add laravel/homestead --box-version 9.3.0
sudo -H composer self-update
create your project
composer create-project --prefer-dist laravel/laravel yourLaravelProject
cd yourLaravelProject/
composer require laravel/homestead --dev
Make the homestead file
On Windows
vendor\\bin\\homestead make
On Mac
php vendor/bin/homestead make
If you have "private key cannot be found" error, make sure you have private key in .ssh/ directory by typing below:
ssh-keygen -t rsa -f ~/.ssh/id_rsa
Add below line to Homestead.yaml
version: 9.3.0
Build vagrant box
vagrant up
Get into the box
vagrant ssh
cd code
sudo nano /etc/hosts
# add below line to the file
192.168.10.10 homestead.test
Now you can go to homestead.test and see Laravel website is running!
Set up Laravel Homestead Development environment