https://laravel.tw/docs/4.2/homestead
https://blog.wu-boy.com/2014/09/get-homestead-vagrant-vm-running/
一. 安裝
1. Vagrant Installer
https://www.vagrantup.com/downloads.html
2. Virtual Box
https://www.virtualbox.org/wiki/Downloads
3. git tool
http://git-scm.com/downloads
二. 下指令下載vagrant box 的laravel/homestead
$ vagrant box add laravel/homestead
三. 安裝homestead
$ git clone https://github.com/laravel/homestead.git Homestead
四. 打開.Homestead資料夾,底下的Homestead.yaml 設定對應
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: C:\Users\zxcvbnm2749\Code
to: /home/vagrant/Code
sites:
- map: homesteadwhite
to: /home/vagrant/Code/public
databases:
- homestead
五. 設定電腦host的對應網址
http://192.168.10.10/ homesteadwhite
六. 啟動vagrant up
cd目錄到homestead資料夾,執行指令,就可以成功啟動機器
vagrant up
七. vagrant 指令
vagrant 開機
vagrant upvagrant 關機
vagrant haltvagrant ssh登入
vagrant ssh
八. 連入資料庫方法
因為vagrant預設連入DB是使用內建的mysql:homestead資料庫
DB:localhost
port:33060
帳號:homestead
密碼:secret
設定在laravel的 app\config\local\database.php
如果要更改成自己本機的mysql需要調整此設定檔
'mysql' => array( 'driver' => 'mysql', 'host' => '59.127.xxx.xxx', 'database' => 'white', 'username' => 'xxxx', 'password' => 'xxxx', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ),
沒有留言:
張貼留言