getting virtual host working accross network under xampp

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

getting virtual host working accross network under xampp

Postby spudhead » 05. April 2011 15:32

I've got xampp running on my local (Win7) dev machine.

I'm using virtual hosts to get various dev sites running under that. So relevant bits from my apache/conf/extra/httpd-vhosts.conf look like:

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
DocumentRoot C:/xampp/htdocs
ServerName localhost
</VirtualHost>

<VirtualHost dev.newsite.com>
ServerAdmin me@localhost
DocumentRoot "C:\dev\newsite\build"
ServerName dev.newsite.com
ServerAlias dev.newsite.com
<Directory "C:\dev\newsite\build">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

And the relevant entry in my hosts file:

127.0.0.1 dev.newsite.com

This works fine, from the Win7 machine.

I've also created a virtual machine running WinXP (on the same Win7 machine), so I can test on IE8. I want to access dev.newsite.com from it.

I've commented out the following in httpd-xamp.conf, so the virtual machine can at least see my xampp apache. Probably not the safest but this is all on an internal office network:

#<LocationMatch "^/(?i?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/8
# ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
#</LocationMatch>

And I've added an entry to the hosts file on the WinXP virtual machine, pointing dev.newsite.com at the network IP address of the Win7 machine:
192.168.154.168 dev.newsite.com

That's got me nearly there. But if I start up the WinXP virtual machine and point IE8 at http://dev.newsite.com - I don't get the dev site.

I get the xampp 'welcome' page. In fact, it's redirecting me to:
http://dev.newsite.com/xampp/

What's doing this, and how can I stop it?
spudhead
 
Posts: 3
Joined: 05. April 2011 15:25

Re: getting virtual host working accross network under xampp

Postby Altrea » 05. April 2011 15:48

NameVirtualHost 127.0.0.1:80


Your VHosts just listening to Requests from the local loopback.
If none VHost matches, the first VHost takes effect because thats your default VHost.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: getting virtual host working accross network under xampp

Postby spudhead » 06. April 2011 09:36

Ok, so... I've amended my httpd-vhosts.conf so it now reads like:

Code: Select all
NameVirtualHost 127.0.0.1:80
NameVirtualHost 192.168.154.168:80

<VirtualHost 127.0.0.1:80>
   DocumentRoot C:/xampp/htdocs
   ServerName localhost
</VirtualHost>

<VirtualHost dev.newsite.com>
   ServerAdmin me@localhost
   DocumentRoot "C:\dev\newsite\build"
   ServerName dev.newsite.com
   ServerAlias dev.newsite.com
   <Directory "C:\dev\newsite\build">
      Options Indexes FollowSymLinks Includes ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
</VirtualHost>


But from the virtual machine, http://dev.newsite.com still redirects me to http://dev.newsite.com/xampp

I've tried commenting out the first virtual host entry and the related NameVirtualHost line:

Code: Select all
#NameVirtualHost 127.0.0.1:80
#<VirtualHost 127.0.0.1:80>
#   DocumentRoot C:/xampp/htdocs
#   ServerName localhost
#</VirtualHost>


This had no effect - I'm still getting redirected to an xampp subdirectory... somewhere.

I don't even know which line is doing it.... :(
spudhead
 
Posts: 3
Joined: 05. April 2011 15:25

Re: getting virtual host working accross network under xampp

Postby Sharley » 06. April 2011 09:39

Try this and see if it gets you moving forward:
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName dev.newsite.com
ServerAdmin me@localhost
DocumentRoot "C:/dev/newsite/build"
<Directory "C:/dev/newsite/build" >
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Code: Select all
127.0.0.1 localhost
127.0.0.1 dev.newsite.com

Code: Select all
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/8
    Allow from 192.168.0.0/16
    ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
</LocationMatch>


Code: Select all
192.168.154.168 dev.newsite.com
I think you will know what goes where. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: getting virtual host working accross network under xampp

Postby spudhead » 06. April 2011 12:50

Not only has it got everything working, but it's clarified a couple of things too. Thank you very much :D
spudhead
 
Posts: 3
Joined: 05. April 2011 15:25

Re: getting virtual host working accross network under xampp

Postby Sharley » 06. April 2011 12:54

Your most welcome, good luck. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 89 guests