下載和安裝Git 的git bash、 virtualbox 和 vagrant
在命令行或Git Bash中使用以下命令安裝 Homestead Vagrant box
vagrant box add laravel/homestead
- 在隨意的分盤中用Git Bash中安裝 Homestead
cd D:
git clone https://github.com/laravel/homestead.git Homestead
- 一旦你克隆完 Homestead 的代碼倉庫,即可在 Homestead 目錄中運(yùn)行 bash init.sh命令來創(chuàng)建Homestead.yaml配置文件。該文件在C:\Users\用戶名.homestead中。
bash init.sh
- 配置 Homestead
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders: #windows和hometead兩個系統(tǒng)共享一個文件夾,映射
- map: D:/LaravelWorkSpaces #這個是項目的地址,例如D:\隨便\項目的目錄 1
to: /home/vagrant/Code #這個是homestead系統(tǒng)的地址
sites: #sites屬性可以幫助你可以輕易指定一個 域名來對應(yīng)到 homestead 環(huán)境中的一個目錄上,可以設(shè)置多個應(yīng)用的地址
- map: homestead.app #這個是你項目要設(shè)定在你的瀏覽器上的地址
to: /home/vagrant/Code/blog/public
- map: blog.app #這個是你項目要設(shè)定在你的瀏覽器上的地址
to: /home/vagrant/Code/blog/public
#- map: leimu.local
# to: /home/vagrant/Code/leimu/public
databases:
- homestead
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
必須將在 Nginx sites 中所添加的「域名」也添加到你本機(jī)電腦的 hosts上。hosts文件會將請求重定向至 Homestead 環(huán)境中設(shè)置的本地域名。
192.168.10.10 homestead.app
92.168.10.10 blog.app
- 啟動 Vagrant box
編輯完 Homestead.yaml后,在命令行里進(jìn)入你的 Homestead 目錄并運(yùn)行 vagrant up命令
vagrant up
- 通過 SSH 連接Homestead
$ vagrant ssh
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-38-generic x86_64)
Documentation: https://help.ubuntu.com
Management: https://landscape.canonical.com
Support: https://ubuntu.com/advantage
4 packages can be updated.
0 updates are security updates.
Last login: Tue Nov 22 02:10:45 2016 from 10.0.2.2
- 在瀏覽器上顯示你的網(wǎng)頁.
http://homestead.app:8000