【问题标题】:Laravel Homestead Vagrant - Cannot see site - installing problemsLaravel Homestead Vagrant - 看不到站点 - 安装问题
【发布时间】:2016-12-07 00:41:31
【问题描述】:

我现在已经尝试让它工作了 4 个小时,但我正在苦苦挣扎。

我正在努力让我的宅基地运转起来。我按照这里的安装指南: https://laravel.com/docs/5.2/homestead

我有几个问题:

1.) 当我通过克隆 github 存储库安装宅基地时 - 我在该安装中获得了一个 src 文件夹,在该 src 文件夹中我有这个:src/stubs/Homestead.yaml。当我按照说明在该安装的根目录中运行 bash init.sh 时,它创建了一个 /.homestead 文件夹,其中包含 3 个文件:after.shaliasesHomestead.yml 文件。据我了解,我将修改Homestead.yml 以反映我的环境。问题是哪一个?是在隐藏的.homestead 文件夹中还是在我安装 Homestead 的地方?

2.) 当我在浏览器中转到 http://site1.local:8000/ 时,我得到一个无法访问站点的错误 - 拒绝连接。当我转到http://localhost:8000/ 时,我得到“未指定输入文件”。

3.) 命令行中的 Homestead 命令不被识别为内部或外部命令 - 应该是吗?我读到有类似问题的人应该运行命令homestead up 但我无法识别它。

这是我的 Homestead.yml 文件:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/LaravelProjects/projects
      to: /home/vagrant/Code

sites:
    - map: site1.local
      to: /home/vagrant/Code/Laravel/public

databases:
    - homestead

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

这是我的主机文件:

# 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


#laravel project 1
192.168.10.10 site1.local

我已经更新了我的主机文件。我试过运行vagrant reload --provisionvagrant destroy 以及其他流浪命令,但没有运气。有什么建议吗?

这里是运行vagrant reload --provision的转储

==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 80 (guest) => 8000 (host) (adapter 1)
    default: 443 (guest) => 44300 (host) (adapter 1)
    default: 3306 (guest) => 33060 (host) (adapter 1)
    default: 5432 (guest) => 54320 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 5.0.20
    default: VirtualBox Version: 5.1
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/Radley.Anaya/LaravelProjects/Homestead
    default: /home/vagrant/Code => C:/Users/Radley.Anaya/LaravelProjects/projects
==> default: Running provisioner: file...
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: Running provisioner: shell...
    default: Running: C:/Users/RADLEY~1.ANA/AppData/Local/Temp/vagrant-shell20160801-10000-y9i8nr.sh
==> default: Running provisioner: shell...
    default: Running: script: Creating Site: site1.local
==> default: Running provisioner: shell...
    default: Running: script: Restarting Nginx
==> default: Running provisioner: shell...
    default: Running: script: Creating MySQL Database
==> default: Running provisioner: shell...
    default: Running: script: Creating Postgres Database
==> default: Running provisioner: shell...
    default: Running: script: Clear Variables
==> default: Running provisioner: shell...
    default: Running: inline script
==> default: You are already using composer version 1.2.0 (stable channel).
==> default: Running provisioner: shell...
    default: Running: C:/Users/RADLEY~1.ANA/AppData/Local/Temp/vagrant-shell20160801-10000-i2qk4o.sh

更新

我通过 ssh 进入虚拟机,我的文件夹结构看起来像:Code/first/index.php 我该如何更新它?

我的 Homestead.yml 文件具有不同的目录结构 - 我认为这可能会导致我的问题。我该如何解决?

据我了解,.yml 文件决定了虚拟机的文件夹结构?不是这样吗??

【问题讨论】:

  • 你能粘贴你的主机文件和“vagrant reload --provision”的输出吗?您可以对 Vagrant IP“nmap 192.168.10.10”进行 nmap 并粘贴输出吗?
  • @JesúsAmieiro 如何制作到 Vagrant IP 的 nmap?
  • 你必须安装nmap(安装方法取决于你的主机)nmap.org/download.html然后你必须执行“nmap 192.168.10.10”。此命令将显示您的 Vagrant VM 的开放端口。
  • 如果您可以通过 ssh 进入虚拟机,则问题出在目录映射中。检查目录“~/LaravelProjects/projects/Larevel/pubilc”是否存在,然后尝试配置 VM 机器(vagrant reload --provision)。我的博客中有一本手册,其中包含此信息jesusamieiro.com/how-to-add-a-new-project-in-laravel-homestead
  • @JesúsAmieiro 我看了你的博客,它帮助了我。此命令$ ls /etc/nginx/sites-enabled/ -la 显示我的站点已启用。从网址中删除端口后,我终于能够查看它。这对我有用:http://site1.local 但不是http://site1.local:8000

标签: bash laravel vagrant homestead


【解决方案1】:

已解决

我的映射搞砸了。我 ssh 进入 vm 以验证和更新我的 .yaml 文件,然后配置 vm 并且一切正常。我还必须从我的 url 中删除端口。

【讨论】:

  • 你能发布答案吗? :)
猜你喜欢
  • 2017-08-05
  • 2018-10-15
  • 2015-09-14
  • 2015-06-17
  • 2015-07-22
  • 1970-01-01
  • 2014-07-25
  • 2016-05-21
  • 2021-03-23
相关资源
最近更新 更多