Installing Laravel App with Homestead on MacOS

The following are steps for installing Laravel 7.x on MacOS with Homestead.

Install VirtualBox.

Install Vagrant.

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.

Welcome to UFIS-BNB

Success!

Installing Laravel App with Homestead on Windows 10

The following are steps for installing Laravel 7.x on Windows 10 with Homestead.

Enable hardware virtualization (VT-x) by following this guide:

Install VirtualBox.

Install Vagrant.

Install Git Bash.

Open git bash in administrator mode and install the Homestead Vagrant box. (This should take a few minutes)

$ vagrant box add laravel/homestead

If you get this error:

The box 'laravel/homestead' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you’re logged in via
'vagrant login'. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: [“https://atlas.hashicorp.com/laravel/homestead"]
Error:

then download this MS Visual C++ 2010 x86 Redistributables and install it. Then run the following again:

$ vagrant box add laravel/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

Install Homestead.

$ cd ~
$ git clone https://github.com/laravel/homestead.git ~/Homestead

Create the Homestead configuration file.

$ cd ~/Homestead
$ bash init.sh

Homestead.yaml is created in the directory.

Edit the folders property of the Homestead.yaml file.

folders:
    - map: e:/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

Your Homestead.yaml file should look something like this:

$ cat Homestead.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox

authorize: c:/Users/USER_NAME/.ssh/id_rsa.pub

keys:
    - c:/Users/USER_NAME/.ssh/id_rsa

folders:
    - map: e:/code
      to: /home/vagrant/code

sites:
    - map: homestead.test
      to: /home/vagrant/code/ufis-bnb/public

databases:
    - homestead

features:
    - mariadb: false
    - ohmyzsh: false
    - webdriver: false

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

Add name resolution to your hosts file by adding 192.168.10.10 homestead.test to the end of the file. Go to C:\Windows\System32\drivers\etc\ folder, edit the hosts file in any text editor (text editor must have to open in administrator mode), add the following line to the bottom of the hosts file:

192.168.10.10 homestead.test

Launch Vagrant using git bash.

$ cd C:\User\USER_NAME\Homestead
$ vagrant up
$ 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.

Welcome to UFIS-BNB

Success!