Accessing virtual host across a LAN

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Accessing virtual host across a LAN

Postby winmkt » 28. January 2010 23:50

Need some help accessing a virtual host across a LAN. My virtual host setup works just fine locally on the computer running XAMPP - I can access the different virtual host sites by entering their assigned name in the browser. I have another computer that is connected to the LAN via wireless and it can get to the "Welcome to XAMPP for Windows" page but it can't get to my virtual host site. I did edit the hosts file on this other computer to point the site name to the IP address of the computer running XAMPP however it always takes me to the "Welcome to XAMPP for Windows" page when I enter the name of my virtual host site (http://site2.local) instead of my virtual host site.

I read a few different articles I found on the web to come up with what I added to my httpd-vhosts.conf file - here is my setup (note that I changed the virtual host site names and commented out some paths for security/privacy reasons):

Code: Select all
NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
  DocumentRoot "C:\Program Files\xampp\htdocs"
  ServerName localhost
</VirtualHost>

<VirtualHost site1.local>
  DocumentRoot "C:\Documents and Settings\*****\My Documents\*****\public_html"
  ServerName site1.local

  CustomLog "C:\Documents and Settings\*****\My Documents\*****\public_html\site1.local-access_log" combined
  ErrorLog "C:\Documents and Settings\*****\My Documents\*****\public_html\site1.local-error_log"

  <Directory "C:\Documents and Settings\*****\My Documents\*****\public_html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

<VirtualHost site2.local>
  DocumentRoot "C:\Documents and Settings\*****\My Documents\*****\public_html"
  ServerName site2.local

  CustomLog "C:\Documents and Settings\*****\My Documents\*****\public_html\site2.local-access_log" combined
  ErrorLog "C:\Documents and Settings\*****\My Documents\*****\public_html\site2.local-error_log"

  <Directory "C:\Documents and Settings\*****\My Documents\*****\public_html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
*note that although the paths look the same for my two virtual host sites, it is only that way because i edited them...they are indeed different paths for each virtual host.

This would be what I have in the hosts file of the second computer that I am trying to use to access the virtual site on the computer running XAMPP (once again site name has been edited for security/privacy):

Code: Select all
127.0.0.1           localhost
192.168.1.140       site2.local

Any ideas why I can't access the virtual site from another computer on the LAN?

Eric
winmkt
 
Posts: 2
Joined: 28. January 2010 20:44

Re: Accessing virtual host across a LAN

Postby winmkt » 29. January 2010 03:03

Well, I figured out my own problem. I was looking at some virtual host examples over at apache.org (http://httpd.apache.org/docs/2.0/vhosts/examples.html) and found something that helped me figure out my problem.

I updated my httpd-vhosts.conf file as follows...

Changed NameVirtualHost 127.0.0.1:80 to NameVirtualHost *:80

Changed <VirtualHost 127.0.0.1:80> to <VirtualHost *:80>

Changed <VirtualHost site1.local> to <VirtualHost *:80>

Changed <VirtualHost site2.local> to <VirtualHost *:80>

Tested it first on the computer running XAMPP and the virtual host sites worked fine. Then went to another computer on the LAN and tested and it worked! I'm finally able to access my virtual host site from across the LAN.

Eric
winmkt
 
Posts: 2
Joined: 28. January 2010 20:44


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 143 guests