【问题标题】:Accessing localhost Webserver Over Network通过网络访问 localhost Webserver
【发布时间】:2011-12-15 23:05:02
【问题描述】:

我将本地计算机用作开发服务器。我的主机文件设置如下:

127.0.0.1   localhost
127.0.0.1   cdog24
127.0.0.1   xxxxxorg
127.0.0.1   newintranet

我的 httpd-vhosts.conf 文件设置如下:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "D:\Webserver\htdocs"
    ServerName localhost
    ServerAlias localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "D:\Webserver\htdocs\cdog24"
    ServerName cdog24
    ServerAlias cdog24
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "D:\Webserver\htdocs\xxxxxorg"
    ServerName xxxxxorg
    ServerAlias xxxxxorg
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "D:\Webserver\htdocs\newintranet"
    ServerName newintranet
    ServerAlias newintranet
</VirtualHost>

我正在运行 xampp,可以通过输入分别访问本地机器上的每个站点:

http://localhost http://cdog24 http://xxxxxorg http://newintranet

当我转到网络上的另一台计算机时,我假设我必须输入我的计算机的名称或使用 IP 地址。所以,当我输入以下内容时:

http://machinename/cdog24http://10.1.0.24/newintranet

我被带到一个 404 页面。

我错过了什么?本地计算机或网络上的防火墙不考虑,因为它们都已关闭。我在 Windows 7 本地机器上,远程机器也是 Windows 7。

感谢您的帮助。

【问题讨论】:

    标签: apache xampp localhost virtualhost


    【解决方案1】:

    您需要确定您的机器在网络上的 IP 地址,然后编辑其他机器上的主机文件以指向您的主机

    <your local IP>   cdog24
    <your local IP>   xxxxxorg
    <your local IP>   newintranet
    

    您可能还必须更新 apache conf 文件才能使用您的网络地址而不是 127.0.0.1。

    【讨论】:

      【解决方案2】:

      您需要在远程机器上编辑 hosts 文件(运行浏览器,而不是服务器):

      x.x.x.x   cdog24
      x.x.x.x   xxxxxorg
      x.x.x.x   newintranet
      

      将 x.x.x.x 更改为运行服务器的 Windows 机器的 IP 地址。

      现在您应该可以在浏览器中浏览到 http://cdog24/

      但是,不要添加指向另一台机器的 localhost 条目。 localhost 应始终指向 127.0.0.1!

      【讨论】:

      • 这个解决了。将我的 IP 地址添加到远程机器主机文件中就可以了。谢谢!
      【解决方案3】:

      您是否尝试过仅使用 http://machinename/http://machinename/directory 要求文档根目录指向 htdocs 本身。

      【讨论】:

        猜你喜欢
        • 2013-04-03
        • 1970-01-01
        • 2023-03-17
        • 1970-01-01
        • 2011-06-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-14
        相关资源
        最近更新 更多