参考:https://segmentfault.com/a/1190000014350154?utm_source=tag-newest
https://www.cnblogs.com/davenkin/p/vagrant-virtualbox.html
https://laravel-china.org/topics/2090/homestead-installation-needs-to-know-some-information
https://blog.csdn.net/mrgong_/article/details/78819541
https://www.cnblogs.com/hubing/p/5933779.html
http://laravelacademy.org/post/354.html
https://www.boxueio.com/series/php7-up-and-running/episode/11
https://www.jianshu.com/p/ae9d1261bbd8 (有最新的box下载地址)
http://www.sohu.com/a/200758610_470018 (配置homestead和phpstorm)
1、下载并安装virtualbox,vagrant
2、安装homestead:
git clone https://github.com/laravel/homestead.git Homestead
3、迅雷下载virtualbox(也会中断,但可以继续下载,比起vagrant box add laravel/homestead https://app.vagrantup.com/laravel/boxes/homestead/versions/5.2.0/providers/virtualbox.box)
链接:https://app.vagrantup.com/laravel/boxes/homestead/versions/6.4.0/providers/virtualbox.box
4、添加virtualbox(将virtubox.box 的下载位置改为自己的地址,反斜杠改为斜杠)
vagrant box add laravel/homestead file:///D:/download/virtubox.box
5、在安装homestead的文件夹中
scripts\homestead.rb 把
config.vm.box_version = settings["version"] ||= ">= 6.4.0" 改为 config.vm.box_version = settings["version"] ||= ">= 0"
homestead文件夹下执行命令:
vagrant up
6、可能犯的错误:
-|禁用了virtubox的虚拟网络
-|安装了virtubox6
-|virtubox.exe没有加入到系统path中
==================================================================
之前安装的方式:
1、vagrant box add laravel/homestead
用有线以太网一直有连接超时的报错,改用无限网,速度6,7M/s,不知道是什么鬼。
2、若无法进行上一步,则要在本地先下载box,再使用vagrant box add metadata.json添加box,会报Invalid file://hostname/, expected localhost or 127.0.0.1 or none的错误。
我用的是vagrant 2.0.3 、win10 、virtualBox5.8,改成绝对路径无效果,
网友其他解决方式:
一、换vagrant 2.0.2,未尝试。
二、将metadata.json直接改成路径,也未尝试。
vagrant box add laravel/homestead /path/to/virtualbox.box
windows中执行如下命令
vagrant box add laravel/homestead file:///D:/download/virtubox.box
三、vagrant box add laravel/homestead https://app.vagrantup.com/laravel/boxes/homestead/versions/5.2.0/providers/virtualbox.box (可以)
(备用地址:https://vagrantcloud.com/laravel/boxes/homestead/versions/6.4.0/providers/virtualbox.box)
3、安装homestead:git clone https://github.com/laravel/homestead.git Homestead
4、vagrant ssh登录到虚拟机,并新建laravel项目(项目名与Homestead.yaml中的对应)
composer config -g repo.packagist composer https://packagist.phpcomposer.com
composer create-project --prefer-dist laravel/laravel code
5、配置Homestead.yaml时,需注意共享文件夹的对应
image.png
6、连接数据库
image.png
7、哈哈
image.png
8、常用命令:
开启homestead虚拟机
vagrant up
更改Homestead.yaml后需重新加载
vagrant reload --provision
关闭homestead虚拟机
vagrant halt
删除homestead虚拟机
vagrant destroy
9、配置phpStorm,xDebug
php7.0 -m
sudo ln -snf /etc/php/7.0/mods-available/xdebug.ini /etc/php/7.0/cli/conf.d/20-xdebug.ini
sudo ln -snf /etc/php/7.0/mods-available/xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini
sudo service php7.0-fpm restart
sudo service nginx restart
注意端口号
网友评论