windows 安装laravel Homestead

## 1、安装Homestead

#以下的操作在D盘

安装ComposerGIt BashVirtualBoxVagrant

我的Vagrant 安装目录选择在 D:/vagrant


#打开Git Bash 进入D: /Vagrant

  1. cd D:  
  2. cd Vagrant  

#添加Homestead Vagrant Box 到 Vagrant
  1. vagrant box add laravel/homestead  

如果vagrant 命令未找到,需重启git bash 或重启电脑


#克隆 Laravel Homestead 仓库到 D:/homestead

  1. cd ..  
  2. git clone https://github.com/laravel/homestead.git  
  3. cd homestead  

init.sh 表示 拷贝Homestead.yaml 、after.sh、aliases 到用户目录 ~/.homestead/  下(即 C:\Users\Administrator\.homestead)

Vagrantfile 表示 虚拟机开启时候会自动读取 ~/homestead/ 目录下相关配置文件、如果配置错误则会启动失败


#执行 init.sh

  1. bash init.sh  

#创建本地工作目录
  1. cd ../wamp/www  
  2. mkdir lvhome  
  3. cd lvhome  
我装了wamp、所以我个人就创建在 D:/wamp/www 下、


#安装 laravel

  1. composer create-project laravel/laravel Laravel --prefer-dist  

#配置 SSH
  1. ssh-keygen -t rsa -C "you@homestead"  

#配置windows hosts 文件

打开 C:/Windows/System32/drivers/etc/host 添加

  1. 192.168.10.10   homestead.app  

#配置Homestead.yaml 文件 (在C:\Users\hello\.homestead 目录下)

  1. ---  
  2. ip: "192.168.10.10"  
  3. memory: 2048  
  4. cpus: 1  
  5. provider: virtualbox  
  6.   
  7. authorize: ~/.ssh/id_rsa.pub  
  8.   
  9. keys:  
  10.     - ~/.ssh/id_rsa  
  11.   
  12. folders:  
  13.     - map: ~/Code  
  14.       to: /home/vagrant/Code  
  15.   
  16. sites:  
  17.     - map: homestead.app  
  18.       to: /home/vagrant/Code/Laravel/public  
  19.   
  20. databases:  
  21.     - homestead  
  22.   
  23. variables:  
  24.     - key: APP_ENV  
  25.       value: local  
  26.   
  27. # blackfire:  
  28. #     - id: foo  
  29. #       token: bar  
  30. #       client-id: foo  
  31. #       client-token: bar  
  32.   
  33. # ports:  
  34. #     - send: 93000  
  35. #       to: 9300  
  36. #     - send: 7777  
  37. #       to: 777  
  38. #       protocol: udp  

修改为:
  1. ---  
  2. ip: "192.168.10.10"  
  3. memory: 2048  
  4. cpus: 2  
  5. provider: virtualbox  
  6.   
  7. authorize: ~/.ssh/id_rsa.pub  
  8.   
  9. keys:  
  10.     - ~/.ssh/id_rsa  
  11.   
  12. folders:  
  13.     - map: D:/wamp/www/lvhome  
  14.       to: /home/vagrant/Code  
  15.   
  16. sites:  
  17.     - map: homestead.app  
  18.       to: /home/vagrant/Code/Laravel/public  
  19.   
  20. databases:  
  21.     - homestead  
  22.   
  23. variables:  
  24.     - key: APP_ENV  
  25.       value: local  
Folders 是本地与虚拟机的目录映射、即 本地的D:/wamp/www/lvhome 与虚拟机的 Code 是同步的、修改任何一方、双方都改变

Sites 是域名访问的目录、上面hosts 文件配置 homestead.app 会直接访问Code/Laravel/public 目录,也是 wamp/www/lvhome/Laravel/public 目录


#启动虚拟机

  1. cd d:/homestead  
  2. vagrant up  
#访问 http://homestead.app:8000 即安装完成
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值