【问题标题】:How to access my localhost from another PC in LAN?如何从局域网中的另一台 PC 访问我的本地主机?
【发布时间】:2012-04-04 20:44:06
【问题描述】:

我正在使用 WAMP 服务器来运行我的网站。我正在使用 Windows 7。

我在两台 PC 之间创建了 LAN,我想从第二台 PC 访问我的本地主机。
请注意,我没有使用 Internet 连接,因此无法使用 IP 地址。

请给我你的建议。

【问题讨论】:

  • LAN 上的计算机仍然可以获取 IP 地址,Internet 与它没有任何关系。除非您使用交叉电缆或其他东西。我们需要更多详细信息来回答您的问题。

标签: windows-7 wamp lan


【解决方案1】:

你必须编辑httpd.conf并找到这一行:Listen 127.0.0.1:80

然后写下您为 LAN 设置的所需 IP。不要使用自动 IP。
例如:Listen 192.168.137.1:80

我使用192.167.137.1 作为我的 Windows 7 局域网 IP。重新启动 Apache 并享受共享。

【讨论】:

  • 或者Listen *:80也可以。
【解决方案2】:

IP 可以是任何 LAN 或 WAN IP 地址。但是您需要将防火墙连接设置为允许。

设备与 webserver pc 的连接可以通过 LAN 或 WAN (即通过 wifi、connectify、adhoc、cable、mypublic wifi 等)

您应该按照以下步骤操作:

  1. 转到控制面板
  2. 入站规则 > 新规则
  3. 点击端口>下一步>特定本地端口>输入8080>下一步>允许连接>
  4. 下一步 > 勾选所有(域、私有、公共)> 指定任何名称
  5. 现在您可以通过任何设备(笔记本电脑、移动设备、台式机等)访问您的本地主机。
  6. 在浏览器 url 中输入 ip 地址为 123.23.xx.xx:8080 以通过任何设备访问 localhost。

此 IP 将属于具有网络服务器的设备。

【讨论】:

  • 这可能与公共 IP 地址有关吗?所以我可以把它分享给全世界?
【解决方案3】:

实际上,您不需要互联网连接即可使用 IP 地址。 LAN 中的每台计算机都有一个内部 IP 地址,您可以通过运行

ipconfig /all

在 cmd 中。

您可以使用服务器的 IP 地址(可能是 192.168.0.x 或 10.0.0.x 之类的)远程访问网站。

如果您找到该 ip 但仍无法访问该网站,则表示 WAMP 未配置为响应该名称(您叫我什么?192.168.0.3?那不是我的名字。我是 Localhost )并且您有修改....../apache/config/httpd.conf

Listen *:80

【讨论】:

    【解决方案4】:

    之后您的电脑连接到其他电脑使用以下 4 个步骤:
    4 个步骤:
    1- 编辑这个文件:httpd.conf
    为此,单击 wamp 服务器并选择 Apache 并选择 httpd.conf
    2- 查找此文本:拒绝全部
    在下面的标签中:

      <Directory "c:/wamp/www"><!-- maybe other url-->
    
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.4/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   AllowOverride FileInfo AuthConfig Limit
        #
        AllowOverride All
    
        #
        # Controls who can get stuff from this server.
        #
    #    Require all granted
    #   onlineoffline tag - don't remove
         Order Deny,Allow
        Deny from all
         Allow from 127.0.0.1
         Allow from ::1
         Allow from localhost
    </Directory>
    

    3- 更改为:拒绝从无
    像这样:

    <Directory "c:/wamp/www">
    
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.4/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   AllowOverride FileInfo AuthConfig Limit
        #
        AllowOverride All
    
        #
        # Controls who can get stuff from this server.
        #
    #    Require all granted
    #   onlineoffline tag - don't remove
         Order Deny,Allow
        Deny from none
         Allow from 127.0.0.1
         Allow from ::1
         Allow from localhost
    

    4- 重启 Apache
    不要忘记重启 Apache 或所有服务!!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-27
      • 2014-12-23
      • 1970-01-01
      • 2011-09-21
      • 2021-09-11
      • 1970-01-01
      相关资源
      最近更新 更多