laravel - window10 - homestead 安装之路
主要步骤
-
安装vagrant、VirtualBox、git 工具
-
vagrant box add laravel/homestead
-
克隆homestead 仓库下来
-
配置Homestead.yaml
-
初始化vagrant配置,启动vagrant 并登录虚拟机
参考相关文章:
第一步:下载vagrant、VirtualBox、git 工具步骤省略,比较简单
第二步:
直接命令行 vagrant box add laravel/homestead 的话,下载会很慢
中间试过直接用迅雷下载,但是还是有点麻烦,要自己在创建metadata.json文件
下载好 lc-homestead-8.2.1-2019112300 box压缩包,解压,然后进入目录执行命令 vagrant box add metadata.json 添加
需要注意的是:
将metadata.json文件中的 name字段修改为laravel/homestead,在后面vagrant up的时候会去检查box 'laravel/homestead'是否存在的,如果找不到,就会又远程下载
/f/lc-homestead-8.2.1-2019112300 $ vagrant box add metadata.json ==> box: Loading metadata for box 'metadata.json' box: URL: file://F:/lc-homestead-8.2.1-2019112300/metadata.json ==> box: Adding box 'laravel/homestead' (v8.2.1) for provider: virtualbox box: Downloading: virtualbox.box box: ==> box: Successfully added box 'laravel/homestead' (v8.2.1) for 'virtualbox'!
查看是否导入box成功
$ vagrant box list laravel/homestead (virtualbox, 8.2.1)
第三步: 克隆homestead 仓库下来
$cd ~ $ git clone https://git.coding.net/summerblue/homestead.git Homestead
进入 ~/homestead 文件夹
vagrant up
错误
$ vagrant up Bringing machine 'homestead-7' up with 'virtualbox' provider... ==> homestead-7: Importing base box 'laravel/homestead'... ==> homestead-7: Matching MAC address for NAT networking... ==> homestead-7: Checking if box 'laravel/homestead' version '8.2.1' is up to date... ==> homestead-7: Setting the name of the VM: homestead-7 Vagrant is currently configured to create VirtualBox synced folders with the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant guest is not trusted, you may want to disable this option. For more information on this option, please refer to the VirtualBox manual: https://www.virtualbox.org/manual/ch04.html#sharedfolders This option can be disabled globally with an environment variable: VAGRANT_DISABLE_VBOXSYMLINKCREATE=1 or on a per folder basis within the Vagrantfile: config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false ==> homestead-7: Clearing any previously set network interfaces... ==> homestead-7: Preparing network interfaces based on configuration... homestead-7: Adapter 1: nat homestead-7: Adapter 2: hostonly ==> homestead-7: Forwarding ports... homestead-7: 80 (guest) => 8000 (host) (adapter 1) homestead-7: 443 (guest) => 44300 (host) (adapter 1) homestead-7: 3306 (guest) => 33060 (host) (adapter 1) homestead-7: 4040 (guest) => 4040 (host) (adapter 1) homestead-7: 5432 (guest) => 54320 (host) (adapter 1) homestead-7: 8025 (guest) => 8025 (host) (adapter 1) homestead-7: 27017 (guest) => 27017 (host) (adapter 1) homestead-7: 22 (guest) => 2222 (host) (adapter 1) ==> homestead-7: Running 'pre-boot' VM customizations... ==> homestead-7: Booting VM... There was an error while executing `VBoxManage`, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below. Command: ["startvm", "259ca5bb-1f5d-401b-bf59-c1fba7b44e1b", "--type", "headless"] Stderr: VBoxManage.exe: error: Not in a hypervisor partition (HVP=0) (VERR_NEM_NOT_AVAILABLE). VBoxManage.exe: error: VT-x is disabled in the BIOS for all CPU modes (VERR_VMX_MSR_ALL_VMX_DISABLED) VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole
解决方法:
开启电脑Hyper-V功能,需两步操作
-
重启电脑,进入bios打开 开启intel VT选项
开启两个选项:
-
“Intel Virtualization Techonlogy”设置 【Enabled】
-
“VT-d”(搭载Intel CPU机台)开启
-
window 打开 “程序与功能”启用或关闭Window功能 打开Hyper-v功能
第四步:配置Homestead.yaml
folders: - map: ~/code to: /home/vagrant/code sites: - map: laraveltest.test to: /home/vagrant/code/laraveltest/public
然后系统host文件添加ip地址对应的域名
subl C:/Windows/System32/Drivers/etc/hosts
添加
192.168.10.10 laraveltest.test
第五:启动虚拟机并进入
进入~/homestead文件夹,启动 vagrant
vagrant up
成功启动,登录 Homestead 虚拟机上
$ vagrant ssh Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-64-generic x86_64) Thanks for using _ _ _ | | | | | | | |__ ___ _ __ ___ ___ ___| |_ ___ __ _ __| | | '_ \ / _ \| '_ ` _ \ / _ \/ __| __/ _ \/ _` |/ _` | | | | | (_) | | | | | | __/\__ \ || __/ (_| | (_| | |_| |_|\___/|_| |_| |_|\___||___/\__\___|\__,_|\__,_| * Homestead v10.0.0 released * Settler v9.1.0 released 257 packages can be updated. 103 updates are security updates. Last login: Sat Nov 23 10:55:29 2019 from 10.0.2.2
homestead mysql 账号密码
用户名:homestead
密码:secret
命令行登陆:$ mysql -uhomestead -psecret