作者:平凡屋之换 | 来源:互联网 | 2023-09-10 20:39
开发环境Win7VirtualBox5.1.14Vagrant1.8.1_91.安装VirtualBox5.1.14,Githttps:www.virtualbox.org
开发环境
- Win7
- VirtualBox5.1.14
- Vagrant 1.8.1_9
1.安装VirtualBox5.1.14,Git
https://www.virtualbox.org/
以下命令都在Git Bash里运行。
建立项目文件夹
c:/documents/mytwitter_project
2.安装Vagrant
https://www.vagrantup.com/downloads.html
执行命令
vagrant box add laravel/homestead
这一步很可能会失败,可以使用离线下载。
--
稍等会看到下载地址。
Ctrl+C取消命令,然后使用迅雷或浏览器离线下载box文件。
下载完,放在C:/Documents/vagrant/laravel.box
运行
vagrant box add laravel/homestead file:///C:/Documents/vagrant/laravel.box
vagrant box list
3.克隆homestead
git clone https:
#也可以通过composer安装,过程composer的过程省略
#composer global require "laravel/homestead=~2.0"
cd Homestead
bash init.sh
据说文件自动存放在C:\Users\Administrator.homestead下,我这没成功,我手工把Homestead拷到Administrator下,然后执行
mv Homestead ./homestead
4.修改C:\Documents\homestead\resources\Homestead.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: /Users/Administrator/.ssh/id_rsa.pub
keys:
- /Users/Administrator/.ssh/id_rsa
folders:
- map: C:/Documents/mytwitter_project
to: /home/vagrant/mytwitter
sites:
- map: laravel.app
to: /home/vagrant/mytwitter/public
variables:
- key: APP_ENV
value: local
5.生成ssh公钥
ssh-keygen -t rsa -C "you@homestead"
6.修改hosts
192.168.10.10 laravel.app
7.初始化 homestead 虚拟机
cd .homestead
vagrant init
修改homestead/Vagrantfile
config.vm.box = "base"
为
config.vm.box = "laravel/homestead"
vagrant up
vagrant ssh 连接虚拟机
连接信息
- IP:127.0.0.1
- 端口号:2222
- 用户名:vagrant
- 密码:vagrant
参考:
http://laravelacademy.org/post/354.html