Skip to content

Instantly share code, notes, and snippets.

@kevyworks
Last active April 2, 2020 00:29
Show Gist options
  • Save kevyworks/29b836a93d573935237775f27eebeaae to your computer and use it in GitHub Desktop.
Save kevyworks/29b836a93d573935237775f27eebeaae to your computer and use it in GitHub Desktop.
Laravel Homestead

Laravel Homestead

Credits from: https://tutsforweb.com/installing-laravel-homestead-on-windows-step-by-step/

Check What?

Virtualization

Disable Hyper-V and Intel VT-x or Intel Virtualization Technology must be enabled in Bios

Windows 10 Super+S, Type: Control Panel and goto Programs and Features

Download VirtualBox, Vagrant and Git Bash

Add the Homestead Box (1GB+)

vagrant box add laravel/homestead

If you encounter an error refer to Installing Homestead Box - https://tutsforweb.com/installing-laravel-homestead-on-windows-step-by-step#4_Installing_Homestead_Box

Setup Homestead

Open Git Bash

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

Create SSH

If you have already: ~/.ssh/id_rsa.pub, this is optional

$ ssh-keygen -t rsa -C "my_email@example.com"

Edit Homestead.yaml

This is my Homestead.yaml

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
ssl: true
#php: "7.1"
authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: e:/www
      to: /home/vagrant/www
    - map: e:/www/coreapp
      to: /home/vagrant/www/coreapp

sites:
    - map: coreapp.test
      to: /home/vagrant/www/coreapp/public
      php: "7.1"
      schedule: true

databases:
    - coreapp_livev2

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

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

Edit host file

*In windows this is located at: C:\Windows\System32\drivers\etc* ..and this is my host file

192.168.10.10 coreapp.test

Create a .bash_profile

I cloned homestead to my SDCard which is E:/ drive and this is my .bash_profile for Homestead alias

alias ..="cd .."
alias vm="ssh vagrant@127.0.0.1 -p 2222"
function homestead() {
 ( cd /e/Homestead && vagrant $* )
}

Using Windows Terminal?

I added a Bash profile to profiles.json file, using GitBash

{
  "closeOnExit" : true,
  "colorScheme" : "Campbell",
  "commandline" : "C:/Progra~1/Git/bin/bash.exe --cd-to-home --init-file ~/.bash_profile",
  "cursorColor" : "#FFFFFF",
  "cursorShape" : "bar",
  "fontFace" : "Dejavu sans mono",
  "fontSize" : 10,
  "historySize" : 9001,
  "icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
  "name" : "Bash",
  "guid" : "{3e471859-5554-4f08-8219-6023820d85d1}",
  "padding" : "10, 0, 10, 10",
  "snapOnInput" : true,
  "acrylicOpacity" : 0.75,
  "useAcrylic" : false,
  "tabTitle" : "Bash "
},
{
  "closeOnExit" : true,
  "colorScheme" : "Campbell",
  "commandline" : "C:/Progra~1/Git/bin/bash.exe --cd-to-home --init-file ~/.bash_profile -c \"export TERM=xterm-256color && cd /e/Homestead && vagrant up && vagrant ssh && echo -e '\n' && (read -n 1 -p 'Press Y/y to stop vagrant, or any key to continue...' RESP && echo -e '\n' && [[ $RESP =~ ^(y|Y)$ ]] && vagrant halt || vagrant status) && bash\"",
  "cursorColor" : "#FFFFFF",
  "cursorShape" : "bar",
  "fontFace" : "mononoki",
  "fontSize" : 13,
  "historySize" : 9001,
  "icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
  "name" : "Homestead SSH",
  "guid" : "{3e471859-5554-4f08-8219-6023820d85d2}",
  "padding" : "10, 0, 10, 10",
  "snapOnInput" : true,
  "useAcrylic" : false,
  "tabTitle" : "Bash "
}

Close git bash and running homestead should work.

Adding SSL to your Homestead

Refer: https://medium.com/dinssa/ssl-certificates-laravel-homestead-windows-https-f83ec8b3198

$ homestead ssh
$ cd /etc/nginx/ssl
$ cp ca.homestead.homestead.crt /home/vagrant/www
  • Open your web browser’s setting & select Advanced: Google Chrome: chrome://settings Mozzila Firefox: about:preferences#privacy
  • Find Manage / View Certificates.
  • Select Import and browse for the certificate you just copied from your virtual machine on to your local machine.
  • Under the section labelled Place all certificates in the following store, find and select Trust Root Certification Authorities.
  • Now you’re ready and just need to restart your web browser.
# Homestead.yaml (Edit Homestead.yaml above)
ssl: true

Start Homestead (via Git Bash)

$ homestead up

How to Downgrade NodeJS

$ homestead ssh
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
$ sudo npm install -g n
$ source ~/.bashrc
$ nvm uninstall <current version>
$ nvm install v11.15.0
$ nvm use v11.15.0
$ node -v

Connecting to DB

MySQL Host: 10.0.2.15 or 127.0.0.1
Username: homestead
Password: secret
Database: (empty)
Port:     (empty)

SSH HOST:   192.168.10.10
SSH User:   vagrant
SSH Key:    ~/.ssh/id_rsa
SSH PORT:   (empty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment