## 1、安装Homestead
#以下的操作在D盘
安装Composer,GIt Bash ,VirtualBox,Vagrant
我的Vagrant 安装目录选择在 D:/vagrant
#打开Git Bash 进入D: /Vagrant
- cd D:
- cd Vagrant
#添加Homestead Vagrant Box 到 Vagrant
- vagrant box add laravel/homestead
如果vagrant 命令未找到,需重启git bash 或重启电脑
#克隆 Laravel Homestead 仓库到 D:/homestead
- cd ..
- git clone https://github.com/laravel/homestead.git
- cd homestead
init.sh 表示 拷贝Homestead.yaml 、after.sh、aliases 到用户目录 ~/.homestead/ 下(即 C:\Users\Administrator\.homestead)
Vagrantfile 表示 虚拟机开启时候会自动读取 ~/homestead/ 目录下相关配置文件、如果配置错误则会启动失败
#执行 init.sh
- bash init.sh
#创建本地工作目录
- cd ../wamp/www
- mkdir lvhome
- cd lvhome
#安装 laravel
- composer create-project laravel/laravel Laravel --prefer-dist
#配置 SSH
- ssh-keygen -t rsa -C "you@homestead"
#配置windows hosts 文件
打开 C:/Windows/System32/drivers/etc/host 添加
- 192.168.10.10 homestead.app
#配置Homestead.yaml 文件 (在C:\Users\hello\.homestead 目录下)
将
- ---
- ip: "192.168.10.10"
- memory: 2048
- cpus: 1
- provider: virtualbox
- authorize: ~/.ssh/id_rsa.pub
- keys:
- - ~/.ssh/id_rsa
- folders:
- - map: ~/Code
- to: /home/vagrant/Code
- sites:
- - map: homestead.app
- to: /home/vagrant/Code/Laravel/public
- databases:
- - homestead
- variables:
- - key: APP_ENV
- value: local
- # blackfire:
- # - id: foo
- # token: bar
- # client-id: foo
- # client-token: bar
- # ports:
- # - send: 93000
- # to: 9300
- # - send: 7777
- # to: 777
- # protocol: udp
修改为:
- ---
- ip: "192.168.10.10"
- memory: 2048
- cpus: 2
- provider: virtualbox
- authorize: ~/.ssh/id_rsa.pub
- keys:
- - ~/.ssh/id_rsa
- folders:
- - map: D:/wamp/www/lvhome
- to: /home/vagrant/Code
- sites:
- - map: homestead.app
- to: /home/vagrant/Code/Laravel/public
- databases:
- - homestead
- variables:
- - key: APP_ENV
- value: local
Sites 是域名访问的目录、上面hosts 文件配置 homestead.app 会直接访问Code/Laravel/public 目录,也是 wamp/www/lvhome/Laravel/public 目录
#启动虚拟机
- cd d:/homestead
- vagrant up