Config Vagrant for Laravel
http://www.rubycoloredglasses.com/2015/09/vagrant-ssh-failure-connection-closed-by-remote-host/
https://laravel.com/docs/5.6/homestead
1) install virtualbox
2) install vagrant
3) check for vagrant:
$ vagrant -v
4) $ vagrant box add laravel/homestead
5) cd to home directory, then:
$ git clone https://github.com/laravel/homestead.git ~/Homestead
6) cd into Homestead, then:
$ bash init.sh
7) cd into ~/.homestead
$ vim Homestead.yaml:
Note the IP given, is not 127.0.0.1
You will need this IP below to put to your .env credentials in your sites
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
# MAIN FOLDERS FOR OUR APPLICATIONS, we have a "www" directory in our home dir
folders:
- map: ~/www
to: /home/vagrant/www
# MAPPING FOR OUR SITES
sites:
- map: jc.test
to: /home/vagrant/www/jc/public
- map: larasnippet.test
to: /home/vagrant/www/larasnippet/public
databases:
- jc
- larasnippet
8) if SSH keys are not set:
$ cd .ssh
$ ssh-keygen -t rsa -C "myname@domain.com"
9) edit hosts in the Host machine, Note the IP given in Homestead.yaml
192.168.10.10 jc.test
192.168.10.10 larasnippet.test
** YOUR ENV APPLICATIONS FILE SHOULD LOOK LIKE ***
DB_CONNECTION=mysql
DB_HOST=192.168.10.10
DB_PORT=3306
DB_DATABASE=larasnippet
DB_USERNAME=homestead
DB_PASSWORD=secret
YOU CAN USE the same username/password for all since the only thing changing
HERE IS THE DB_DATABASE, AND DB_HOST
YOU CAN CONNECT VIA SQL PRO:
host:192.168.10.10
database:larasnippet
user:homestead
pass:secret
10) cd to ~/Homestead
$ vagrant up
11) $ vagrant ssh
** if it cant connect to the virtual machine, go to Virtualbox settings > network > check the [connected] checkbox
12) Anything that is created/updated/deleted , will be updated in the www directory of the virtual machine
and vice versa
13) SSH into vagrant:
$ vagrant SSH
$ composer global require "laravel/installer"
14) cd into the www dir:
$ cd www
$ laravel new laravelcms
15) Provision the machine if you made changes to Homestead.yaml, in the HOST machine
$ cd Homestead
$ vagrant provision