Accessing virtual host from computer on same local network

断了今生、忘了曾经 提交于 2019-12-02 16:00:25

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.

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>

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.. :)

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)You can use this via command line:

httpd -D DUMP_VHOSTS

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

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

Have you try to include the port at your client host's file?

192.168.1.7:81 project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!