【问题标题】:can't run my laravel app on windows through vagrant无法通过 vagrant 在 Windows 上运行我的 laravel 应用程序
【发布时间】:2015-12-14 11:34:08
【问题描述】:

我正在关注启动和运行 laravel 的 larcast 教程,我已经将 laravel 设置为工作正常,现在我希望通过我的 Windows 上的 vagrant 实现它。 但是当我浏览“todo.app:8000”时,我无法运行我的应用程序,这些页面没有响应并显示消息“网页不可用”。
但是,当我第一次设置它时,我可以通过“localhost:8000”访问该页面,并且我在没有“php artisan serve”命令的情况下访问它,但是无法使用“todo.app:8000”之后我更新了作曲家并重新启动了机器,事情变得更糟了,现在我什至无法使用“localhost:8000”访问它>" 而如果我运行 "php artisan serve" 它工作正常。 运行 homestead、vagrant 或 laravel 命令也没有错误,它们工作得很好。
谁能告诉我我做错了什么? 这是我的 homestead.yml 文件

---

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

authorize: ~/.ssh/id_rsa.pub

keys:
- ~/.ssh/id_rsa

folders:
- map: ~/code
  to: /home/vagrant/code

sites:
- map: todo.app
  to: /home/vagrant/code/learning-laravel-5/public

databases:
- homestead
variables:
- key: AAP_ENV
value: local
# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

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

这些是我在 windows 主机文件中所做的配置

    # 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
127.0.0.1 todo.app
127.0.0.1 mynew.app

如果还需要其他任何内容,请同时告知。我已经花了一整天的时间来弄清楚,但我被困在这里。提前致谢

【问题讨论】:

    标签: php laravel-5 vagrant homestead


    【解决方案1】:

    有几点需要解决(1 和 2 应该可以解决您的问题):

    1. 您不能让 todo.app 指向您的 127.0.0.1,您需要将 127.0.0.1 更改为您的 VM 的 IP (192.168.10.10)

    2. 应该是http://todo.app 而不是http://todo

    3. 你有端口转发吗?从您的评论摘录中,您是否将 80 转发到 8000,或者您是否在 VM 的 8000 端口上运行了某些东西?

    如果你做 localhost:8000,它假设你已经将端口 80 从 VM 转发到主机上的 8000,而 todo.app:8000 将直接指向 VM 并从 8000 端口获取正在运行的内容虚拟机。

    1. 你有一个固定的IP地址,所以你可以使用http://192.168.10.10来访问你的laravel

    【讨论】:

    • 抱歉,我在问题中跳过了 .app。它是 todo.app:8000,但我已将点从 127.0.0.1 更改为 192.168.10.10,这是我的 VM 的 IP。而且我还没有转发任何端口,但是当我发出命令“vagrant up”时,很少有关于进行端口转发的行,但是问题仍然是一样的,出于某种原因,我不知道如何但我再次得到结果“localhost:8000”而不做“php artisan serve”
    猜你喜欢
    • 1970-01-01
    • 2012-02-18
    • 2022-07-08
    • 1970-01-01
    • 1970-01-01
    • 2014-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多