如何确定在Homestead运行的Laravel项目

时间:2016-10-03 01:55:09

标签: laravel laravel-5.2 homestead

所以我有两个在宅基地运行的laravel项目。一切都在项目所在的PC上运行良好。但是在网络中的另一台计算机中,它不会起作用。

这是我的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

# redirecting this is just a bad idea 127.0.0.1       localhost
# redirecting this is just a bad idea 127.0.0.1       localhost
# redirecting this is just a bad idea 127.0.0.1       localhost
# redirecting this is just a bad idea 127.0.0.1       localhost
# redirecting this is just a bad idea 127.0.0.1       localhost
#127.0.0.1      localhost
192.168.10.10   laravel.dev
192.168.10.10   homestead.app

我的主持人文件:

192.168.1._:8000 (my PC's IP)

我可以在我的电脑上运行这两个项目没有问题。但是,当我倾向于在网络中的其他计算机上运行这些项目时,它就无法工作。我只能运行键入192.168.10.10 laravel.dev 192.168.10.10 homestead.app 的第二个项目。

如果网络中的其他计算机具有相同的IP,我如何确定它们?就像在我的主机文件中一样:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# wait host to finish reboot, check specific port connection (usually ssh port if you want to exec remote commands)
while True:
    try:
        s.connect(('hostname', 22))
        print "Port 22 reachable"
        break
    except socket.error as e:
        print "rebooting..."
# continue
s.close()

1 个答案:

答案 0 :(得分:0)

您正在使用分配了IP地址192.168.10.10的虚拟机

运行Homestead VM的计算机将通过该IP地址访问它。

您的hosts文件是VM Homestead的IP地址的别名。

...

如果某人接受了您实例的vagrantFile,他们可以使用VM的详细信息启动他们的Homestead(aka Vagrant)实例。

使用vagrantFile的新机器需要编辑其主机文件,以匹配其Homestead / Vagrant.yaml文件中列出的相同IP地址。

如果您想使用端口通过本地计算机ip地址提供laravel实例,可以使用

php artisan serve 
来自项目根目录的

命令。但是,请注意可能需要sql和composer的其他依赖项。