Homestead 安装需要知道的一些信息

链接

如果你看这篇文章的目的是 Homestead 安装加速的话,二话不说,到百度盘先找最新版本的下载:http://pan.baidu.com/s/1hrN55w4 ,一边下载一边再来看这个文章。

Homestead Box 版本

默认使用命令:

vagrant box add laravel/homestead

安装的盒子是最新版本,如当前最新版本的 Homestead 为 v0.4.4。

Laravel 社区对新技术保持比较开放的姿态,所以 Homestead 的最新版一般都使用比较新的软件,如 PHP7,推崇 HHVM,MYSQL 5.7 等。

如果你因特殊原因,想使用老版本的话,如项目需要使用 PHP5.6(v0.3.3 版本)。

Homestead 的所有 box 版本信息:https://atlas.hashicorp.com/laravel/boxes/...

下载指定版本的命令:

$ vagrant box add laravel/homestead --box-version=0.3.3
$ vagrant box add laravel/homestead --box-version=0.2.7

file

上面的几个版本可前往百度盘下载:http://pan.baidu.com/s/1hrN55w4

下载加速

国内因为网络的原因,默认的盒子安装命令 vagrant box add laravel/homestead 变得不适用。

你可以使用以下方法来加速下载和添加盒子。

1. 下载链接

首先获取盒子最终下载链接:

然后就可以使用第三方多线程,支持断点续传的工具进行下载了。

注意,请勿使用迅雷离线下载,亲测下载后的文件会损坏。

我把目前几个大版本下载上传到百度盘,可前往下载 -> http://pan.baidu.com/s/1o7KB2ZK

附上文件的 CheckSum:

➜  Boxes openssl sha1 homestead-virtualbox-0.2.7.box
SHA1(homestead-virtualbox-0.2.7.box)= 76e67b203a39f77d617ad9ed00d2aec0c79e7680
➜  Boxes openssl sha1 homestead-virtualbox-0.4.4.box
SHA1(homestead-virtualbox-0.4.4.box)= 059821e503c5441e9243edd687e061e5ce0a1bec
➜  Boxes openssl sha1 homestead-virtualbox-0.3.3.box
SHA1(homestead-virtualbox-0.3.3.box)= 41967c26e7fd8b0fae84c3ecbd0e4058c0ab2bb1

2. 导入盒子

下载下来的 .box 文件,可以使用以下方法导入:

.box 的同文件夹下创建一个 metadata.json 文件,内容为以下

{
    "name": "laravel/homestead",
    "versions": 
    [
        {
            "version": "0.4.4",
            "providers": [
                {
                  "name": "virtualbox",
                  "url": "homestead-virtualbox-0.4.4.box"
                }
            ]
        }
    ]
}

字段说明

  • version - 可以指定当前盒子导入的版本标示;
  • url - 支持 绝对文件路径相对文件路径

运行以下命令导入:

vagrant box add metadata.json

运行 list 命令查看是否添加成功:

vagrant box list

操作截图:

file

感谢 @solarhell 提供的此方法,他的博文 - 使用Homestead搭建开发环境

Homestead 版本

所有的 homestead 历史版本可以在这里看到:https://github.com/laravel/homestead/relea...

使用以下命令可查看 homestead 版本:

$ homestead -version
Laravel Homestead version 2.2.1

安装 homestead 特定版本:

$ composer global require "laravel/homestead:~2.2.0"

删除 homestead 之前的版本,然后使用最新版本:

$ composer global remove laravel/homestead
$ composer global clear-cache
$ composer global require laravel/homestead
$ vagrant destroy && vagrant up

指定 Homestead 使用某个版本的 BOX

不同版本的 Homestead 默认都会特殊指定一个 BOX 版本,如果你想使用不一样的版本:

homestead edit

然后增加配置项:

// specify the box version
version: "0.4.4"

然后,打开 virtual box 软件,删除 homestead,然后重新

homestead up

启动成功后使用的即是你指定的 BOX 了。

摈弃世俗浮躁,追求技术精湛
本帖已被设为精华帖!
Summer
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 14
Summer

@solarhell 赞一个 :+1: 。

关于文件损坏,迅雷离线测试了是文件损坏掉的。刚刚跑去百度网盘把文件都下下来测试,上传的几个文件的 checksum 都没问题,并且都能成功导入。

7年前 评论

@icrz 应该不是,我觉得是不是已经执行过init.sh就不能再装一次了?我是这么认为的

7年前 评论
Luff

问下, 下面的错误怎么搞?

vagrant box add --name laravel/homestead metadata.json
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'laravel/homestead' (v0) for provider: 
    box: Unpacking necessary files from: file:///home/ibenchu010/%E4%B8%8B%E8%BD%BD/metadata.json
The box failed to unpackage properly. Please verify that the box
file you're trying to add is not corrupted and try again. The
output from attempting to unpackage (if any):

bsdtar: Error opening archive: Unrecognized archive format
7年前 评论
Summer

@QiyueShiyi box 文件坏掉了,重新下。

7年前 评论
Luff

@Summer box 文件是好的,我更改了 Vagrantfile 文件,就安上了,
再问下,我虚拟机安好了,在浏览器里也显示了,vagrant ssh 进入后的 mysql 初始密码是多少?

vagrant@homestead:~/Code/weixiu$ mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
7年前 评论
Summer

请看下这个文档:链接数据库

7年前 评论

Homestead的版本本身是在升级的,我下载的box是 homestead-virtualbox-0.4.4.box 这时候Homestead本身就需要切换到3.1.0 tag下:

➜ Homestead git:(master) git checkout tags/v3.1.0 -b v3.1.0
Switched to a new branch 'v3.1.0'
➜ Homestead git:(v3.1.0) bash init
bash: init: No such file or directory
➜ Homestead git:(v3.1.0) pwd
/Users/qk/Homestead
➜ Homestead git:(v3.1.0) bash init.sh
overwrite /Users/qk/.homestead/Homestead.yaml? (y/n [n]) y
overwrite /Users/qk/.homestead/after.sh? (y/n [n]) y
overwrite /Users/qk/.homestead/aliases? (y/n [n]) y
Homestead initialized!
➜ Homestead git:(v3.1.0)
➜ Homestead git:(v3.1.0) cd ~/Homestead
➜ Homestead git:(v3.1.0) vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:

The host path of the shared folder is missing: ~/Code
➜ Homestead git:(v3.1.0) 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' is up to date...
==> homestead-7: Setting the name of the VM: homestead-7
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
homestead-7: Adapter 1: nat

7年前 评论

请问我在启动vagrant的时候遇到了这样的问题,文件是确定存在的,该如何解决呢?
file
file

7年前 评论

备注下遇到的问题:
file

解决方案:
在./scripts/homestead.rb文件中 把host_ip设置成127.0.0.1

file

6年前 评论

在这个环境下 怎么查看PHP日志

6年前 评论
liuqing_hu

Homestead 5.1.0 版本下载 地址 提取码:kzlc

文章链接: https://www.jianshu.com/p/ae9d1261bbd8

5年前 评论

为什么现在教程都不更新了?

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!