访问来自计算机虚拟主机同一本地网络上 [英] Accessing virtual host from computer on same local network

查看:173
本文介绍了访问来自计算机虚拟主机同一本地网络上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个设置,使我可以访问计算机B A和B都在同一网络上的计算机是在虚拟主机上我的网站。
我使用Win 7的XAMPP。

I am trying to make a setup so that I can access my website on a virtual host in computer A from computer B. Both A and B are on the same network. I am using xampp on Win 7.

因此​​,这里是因为问题出计算机A(服务器)的虚拟主机配置为在httpd-vhosts.conf文件如下:

So here is as the problem goes computer A(server) has a virtual host configuration as follows in the httpd-vhosts.conf file.

NameVirtualHost project:81

<VirtualHost project:81>

    DocumentRoot "D:/work/website"
    ServerName project:81
    <Directory "D:/work/website">
    Options Indexes FollowSymLinks Includes ExecCGI    
    AllowOverride All
    Order Allow,Deny
    Allow from all
    </Directory>
</VirtualHost>

(使用端口81端口80有IIS运行,不很了解这些事情不过)

(using port 81 as port 80 has IIS running, dont know much about these things however)

这种配置本地计算机(服务器)上的罚款。即项目:81在浏览器的地址栏中打开的网站,因为它应该

this configuration works fine on the local machine(server). i.e project:81 in the address bar of the browser opens up the website as it should.

现在在计算机B(客户端)我改了hosts文件包含服务器的IP像虚拟主机名一起: -

Now on computer B(client) I changed the hosts file to contain the IP of the server along with the name of the virtual host like:-

192.168.1.7项目

192.168.1.7 project

现在,当我进入项目:客户端浏览器上81 ..它带我到服务器,但它不是带我到虚拟主机目录,而是需要到默认目录..即在我的情况是

now when I enter project:81 on the client browser .. it takes me to the server but its not taking me to the virtual host directory, instead it takes to the default directory .. i.e in my case is

C:\\ XAMPP \\ htdocs中

C:\xampp\htdocs

现在我卡住,无法使客户端指向当前目标。
所以,任何人都可以提出什么,我做错了还是其他什么东西,我需要以获得从客户端计算机的正确虚拟主机网站做。

Now I am stuck and unable to make the client to point to the current destination. So can anybody suggest what I am doing wrong here or something else I need to do in order to have access to the correct virtual host site from the client machine.

在此先感谢您的帮助。

推荐答案

确定这样濑萨尔瓦多Kahfi对我很老的问题的答复促使我做一些更多的研究和阅读在Apache的网站上。

Ok So Seto El Kahfi's reply to my very old question led me to do some more research and reading on Apache's website.

所以,我得到的是这种情况,我NameVirtualHost指令是不正确的。
所以,取而代之的是,

So what I got is this, my NameVirtualHost directive was improper. So Instead of this,

NameVirtualHost project:81

<VirtualHost project:81>

    DocumentRoot "D:/work/website"
    ServerName project:81
    <Directory "D:/work/website">
    Options Indexes FollowSymLinks Includes ExecCGI    
    AllowOverride All
    Order Allow,Deny
    Allow from all
    </Directory>
</VirtualHost>

我需要做的就是这一点。

What I had to do was this.

NameVirtualHost *:81

<VirtualHost *:81>

    DocumentRoot "D:/work/website"
    ServerName project
    <Directory "D:/work/website">
    Options Indexes FollowSymLinks Includes ExecCGI    
    AllowOverride All
    Order Allow,Deny
    Allow from all
    </Directory>
</VirtualHost>

注意'*',我可以用一个IP地址也有。(在这种情况下,我的服务器(机器A)本地IP)都工作。现在我所要做的就是输入:在客户机上项目81,而我得到了我的眼睛希望看到..:)

Notice the ' * ' , I could have used an IP Address there too.(In this case my server's(machine A) local IP) both work. Now all I had to do is enter "project:81" on the client machine, and I get what my eyes wished to see.. :)

几件事我从这个得到。搜索结果
1)如何使用了NameVirtualHost(或者什么它的目的主要是)。在这里阅读更多
<一href=\"http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost\">http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost
这其中还不错<一个href=\"http://www.thegeekstuff.com/2011/07/apache-virtual-host/\">http://www.thegeekstuff.com/2011/07/apache-virtual-host/

Few things I got from this.

1) How to use NameVirtualHost(or what it's purpose basically is.). Read More here http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost This one is also good http://www.thegeekstuff.com/2011/07/apache-virtual-host/

2)您可以通过命令行中使用这样的:

2)You can use this via command line:

httpd -D DUMP_VHOSTS

了解您的虚拟主机是如何设置(也将给您关于precedence一些警告,如果有什么地方错了你的设置)搜索结果

to know how your virtual hosts are setup(will also give you some warnings regarding precedence if something's wrong with your setup)

3)其他的手势来帮助你让你帮助自己.. :)所以保持帮扶摇摆。

3)Other's gesture to help you makes you help yourself.. :) So keeping helping and rocking.

这篇关于访问来自计算机虚拟主机同一本地网络上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆