The following are steps for installing Laravel 7.x on MacOS with Homestead.
Install VirtualBox.
- Download - Oracle VM VirtualBox https://www.virtualbox.org/wiki/Downloads
Install Vagrant.
- Download - Vagrant by HashiCorp https://www.vagrantup.com/downloads.html
Install the Homestead Vagrant box. (This should take a few minutes)
$ vagrant box add laravel/homestead
When prompted for a provider choice, enter 3
(for VirtualBox).
If you couldn't install homestead using the above command, you can use the following:
$ vagrant box add laravel/homestead https://vagrantcloud.com/laravel/homestead
Install Homestead.
$ git clone https://github.com/laravel/homestead.git ~/Homestead
Create a directory to house your Laravel code.
$ mkdir ~/code
Fork the repository on Bitbucket or Github.
Clone the forked repo into your new directory.
$ cd ~/code
$ git clone https://[your-repo-string]/ufis-bnb.git
Create the Homestead configuration file.
$ cd ~/Homestead
$ bash init.sh
Homestead.yaml
is created in the directory.
$ cat Homestead.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/code
to: /home/vagrant/code
sites:
- map: homestead.test
to: /home/vagrant/code/public
databases:
- homestead
features:
- mariadb: false
- ohmyzsh: false
- webdriver: false
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
View the folders
property of the Homestead.yaml file.
folders:
- map: ~/code
to: /home/vagrant/code
Edit the sites
property of the Homestead.yaml file. In this case, the project directory name
is ufis-bnb
.
sites:
- map: homestead.test
to: /home/vagrant/code/ufis-bnb/public
Add name resolution to hosts file by adding 192.168.10.10 homestead.test
to the end of your hosts file.
$ sudo nano /etc/hosts
192.168.10.10 homestead.test
To save the /etc/hosts file, press CONTROL-X
, then Y
, then return
.
Launch Vagrant.
$ cd ~/Homestead
$ vagrant up
If there aren't id_rsa
(secret key) and id_rsa.pub
(public key) in ~/.ssh
directory, create key files.
$ ssh-keygen -t rsa
Connect to the virtual machine using SSH.
$ vagrant ssh
IMPORTANT: From the VM command line, navigate to the code directory, install dependencies, and set up database.
vagrant@homestead:$ cd ~/code/ufis-bnb
vagrant@homestead:$ composer install
vagrant@homestead:$ php artisan migrate:fresh --seed
View homestead.test
in your browser.
Success!