是啊,宅基地的配置也让我很困惑。我可以推荐你购买电子书Easy Laravel 5 by Jason Gilmore,或read the homestead chapter for free online right here。正是他关于宅基地配置的章节帮助我理解了如何去做。这本电子书还包含许多其他关于 Laravel 5 开发的好东西,并且经常更新。
更新:The Laravel 5 Beauty blog 也有一个非常容易理解的关于如何为 Laravel 5.1 设置宅基地的指南。在 Windows、Linux 和 Mac 上都可以。
也就是说,我会在这里尝试回答您的问题。第 5 步是如何设置宅基地配置。不,您不必自己创建 vagrant/Code 文件夹。这是您提供的路径的别名。
0. Install Composer 如果你还没有。
还将 composer bin 添加到您的路径中:
LINK TO BIGGER VERSION OF PICTURE BELOW
1.确保您已下载最新版本的Vagrant 和Oracle VirtualBox
2.添加laravel框:$ vagrant box add laravel/homestead
3. 安装 Homestead CLI 工具:$ composer global require "laravel/homestead=~2.0"
4. 创建您的 .homestead 文件夹:
$ cd -> 转到您的用户文件夹
$ homestead init -> 创建 .homestead 文件夹
这里还要注意,您需要拥有包含 id_rsa 和 id_rsa.pub 文件的 .ssh 文件夹。如果您的用户文件夹中没有它,follow this guide to get it.。
5. 编辑您的 Homestead.yaml 文件。我将在这里使用我的设置作为示例:
LINK TO BIGGER VERSION OF PICTURE BELOW
6. 转到C:\Windows\System32\drivers\etc\ 并编辑主机文件。它会警告您并要求管理员权限。只需使用管理员控制打开它。
使用您在 homestead.yaml 文件中设置的网址编辑您的主机文件:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
192.168.10.10 phpmyadmin.local
192.168.10.10 lara.local
192.168.10.10 todoparrot.local
7. 运行以下 CLI 命令来配置 vagrant。老实说,我不太确定这是做什么的,但它有点重启 vagrant 所以它与你的 homestead.yaml 和主机配置是最新的。
$ vagrant global-status -> 注意开头出现的小数字。我的是 2a6e97d
$ vagrant provision 2a6e97d
8.运行$ homestead up,让它完成运行并转到你的url,在我的例子中是lara.local。这是我的屏幕:
我希望这不会太令人困惑。第一次建立宅基地真的很痛苦,但是当你“了解”它是如何工作的时候,它就会变成纯粹的幸福。
如果有什么不清楚的地方,请写评论,我会尽力帮忙的:)