Virtual Hosts For some reason wont work

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

Virtual Hosts For some reason wont work

Postby barkermn01 » 23. August 2009 01:32

httpd-vhosts.conf
Code: Select all
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/"
   ServerName loclahost
</VirtualHost>
<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/xampp/"
   ServerName xampp.loclahost
</VirtualHost>
<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/enb/"
   ServerName enb.loclahost
</VirtualHost>
<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/test/"
   ServerName test.loclahost
</VirtualHost>

This wont work for some reason all of my hosts are pointing to the localhost folder "C:/xampp/htdocs" can any one help - i have tryed adding the <Directory path> for each
barkermn01
 
Posts: 1
Joined: 23. August 2009 01:28

Re: Virtual Hosts For some reason wont work

Postby Izzy » 23. August 2009 01:59

Perhaps replace loclahost with localhost or is that a typo?
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Virtual Hosts For some reason wont work

Postby jsmb768ypl » 23. August 2009 19:49

Hi, I am having the same problem.

Code: Select all
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

<VirtualHost 192.168.1.110:80>
   DocumentRoot "C:/xampp/htdocs/"
   ServerName *.fakedns.com
</VirtualHost>
<VirtualHost 192.168.1.120:80>
   DocumentRoot "C:/xampp/htdocs/folder1"
   ServerName *.fakedns.com
</VirtualHost>
<VirtualHost 192.168.1.121:80>
   DocumentRoot "C:/xampp/htdocs/folder2"
   ServerName *.fakedns.com
</VirtualHost>


every time i type one of the other server names thats suppose to link to 192.168.1.120 or 192.168.1.121 it points just to 192.168.1.110 and im not sure why
jsmb768ypl
 
Posts: 6
Joined: 23. August 2009 19:44

Re: Virtual Hosts For some reason wont work

Postby jsmb768ypl » 23. August 2009 22:27

anyone? please. or should i make a new post? Was trying to keep duplicate posts down :P
jsmb768ypl
 
Posts: 6
Joined: 23. August 2009 19:44

Re: Virtual Hosts For some reason wont work

Postby Wiedmann » 24. August 2009 00:44

jsmb768ypl wrote:every time i type one of the other server names thats suppose to link to 192.168.1.120 or 192.168.1.121 it points just to 192.168.1.110 and im not sure why

a) Remove the line "NameVirtualHost *:80", if you want have ip-based vhosts
b) "Servername" can't contain an asterix "*".
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Virtual Hosts For some reason wont work

Postby Izzy » 24. August 2009 00:50

I believe your issue is slightly different to the OP.

You are using NameVirtualHost *.80

Drop the NameVirtualHost *.80 and see if it helps.

Drop the asterisk in front of the ServerName but add an Alias.
Code: Select all
<VirtualHost 192.168.1.110:80>
   DocumentRoot "C:/xampp/htdocs/"
   ServerName fakedns.com
   ServerAlias *.fakedns.com
</VirtualHost>
Repeat the format for the other vhosts.

http://httpd.apache.org/docs/2.2/vhosts/

http://httpd.apache.org/docs/2.2/vhosts/examples.html
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Virtual Hosts For some reason wont work

Postby jsmb768ypl » 24. August 2009 03:00

i did what you told me to and so far im still not getting any thing but, i can now type the static local ip address and get the site to show up local still would like to be able to test it from a url porspect. thanks for any more tips you can give me.

Code: Select all
<VirtualHost 192.168.1.110:80>

    DocumentRoot "F:/xampp/htdocs/"
    ServerName fakedns.com
    ServerAlias test1.fakedns.com
    ##ErrorLog "logs/dummy-host.localhost-error.log"
    ##CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost>

<VirtualHost 192.168.1.121:80>

    DocumentRoot "F:/xampp/htdocs/test2/"
    ServerName fakedns2.com
    ServerAlias test2.fakedns2.com
    ##ErrorLog "logs/dummy-host2.localhost-error.log"
    ##CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>

<VirtualHost 192.168.1.120:80>

    DocumentRoot "F:/xampp/htdocs/test3/"
    ServerName fakedns.com
    ServerAlias test3.fakedns.com
    ##ErrorLog "logs/dummy-host2.localhost-error.log"
    ##CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>



Whats happening is when i go to say "test3.fakedns.com" its pointing me to "test1.fakedns.com" same goes for "test2.fakedns.com" but if i type in 192.168.1.120 or 192.168.1.121 it takes me to the actual site. Not sure if that helps figure out were my problem is.
I have also tryed:

Code: Select all
<VirtualHost 192.168.1.110:80>

    DocumentRoot "F:/xampp/htdocs/"
    ServerName test1.fakedns.com
    ServerAlias test1.fakedns.com
    ##ErrorLog "logs/dummy-host.localhost-error.log"
    ##CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost>

<VirtualHost 192.168.1.121:80>

    DocumentRoot "F:/xampp/htdocs/test2/"
    ServerName test2.fakedns2.com
    ServerAlias test2.fakedns2.com
    ##ErrorLog "logs/dummy-host2.localhost-error.log"
    ##CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>

<VirtualHost 192.168.1.120:80>

    DocumentRoot "F:/xampp/htdocs/test3/"
    ServerName test3.fakedns.com
    ServerAlias test3.fakedns.com
    ##ErrorLog "logs/dummy-host2.localhost-error.log"
    ##CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>


that gives me the same problem.
jsmb768ypl
 
Posts: 6
Joined: 23. August 2009 19:44

Re: Virtual Hosts For some reason wont work

Postby Izzy » 24. August 2009 04:40

You can try adding those IPs with the corresponding name to the Windows Hosts file:
C:\Windows\system32\drivers\etc\Hosts

Example:
127.0.0.1 localhost - should already be there if not add this also.

Then add:
192.168.1.110 fakedns.com - and so on.

Save the file and try again.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Virtual Hosts For some reason wont work

Postby jsmb768ypl » 24. August 2009 05:04

should i do it

192.168.1.110 test1.fakedns.com or 192.168.1.110 fakedns.com

and if its just fakedns.com how will that work since both 110 and 120 are fakedns.com
jsmb768ypl
 
Posts: 6
Joined: 23. August 2009 19:44

Re: Virtual Hosts For some reason wont work

Postby jsmb768ypl » 24. August 2009 05:15

ok i tryed it like this

Code: Select all
127.0.0.1 localhost
192.168.1.110 test1.fakedns.com
192.168.1.120 test2.fakedns2.com
192.168.1.121 test3.fakedns.com


still not working. ive also tryed that mass vhost explaned on the apache server that didnt work either

ps: did i need to restart my server after chaning that file? like restart windows 2003 or no?
jsmb768ypl
 
Posts: 6
Joined: 23. August 2009 19:44

Re: Virtual Hosts For some reason wont work

Postby Izzy » 24. August 2009 05:40

My reply was only an example so you can use my example to create your own Hosts file as you seem to have changed your vhosts file without following my post re ServerAlias.

Did you go to the document links I gave to help you with your issue?

Did you read the comments in the vhost file re verifying your configuration?

You can also do an advanced forum search for virtualhost as this subject has been covered in depth many times in the past.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Virtual Hosts For some reason wont work

Postby jsmb768ypl » 24. August 2009 06:21

ok so i figured id try it the easy way and well it worked...


i turned the nameserver thing back on and to *:80

then i set the <virtualhost *:80>
servername test1.fakedns.com
etc


and then did the rest the same way. ty vary much for your help
jsmb768ypl
 
Posts: 6
Joined: 23. August 2009 19:44

Re: Virtual Hosts For some reason wont work

Postby sean.rowe » 24. August 2009 08:47

I can't get this to work either. Here is my vhost.conf file:

Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "C:web\projects\abba\web"
    ServerName development.abba.laptop
    ServerAlias desktop.abba
    ErrorLog "C:\web\logs\abba\error.log"
    CustomLog "C:\web\logs\abba\access.log" combined
   <Directory "C:\web\projects\abba\web">
      Order allow,deny
      Allow from all
   </Directory>

</VirtualHost>


The server alias and server name both point to localhost (127.0.0.1), but take me to the xampp welcome screen. the error and access logs are created, so I know apache is reading this, but nothing is in them. the redirection isn't working, and i have no idea why. i have stopped and started several times to no avail.
I'm on windows 7.

Can anyone help?
sean.rowe
 
Posts: 2
Joined: 24. August 2009 08:37

Re: Virtual Hosts For some reason wont work

Postby Izzy » 24. August 2009 09:08

Was the coded section a copy and paste from the vhost file?

If so then this line has a typo

DocumentRoot "C:web\projects\abba\web"

Should be

DocumentRoot "C:\web\projects\abba\web"
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Virtual Hosts For some reason wont work

Postby sean.rowe » 24. August 2009 17:56

That was a copy/paste error on my part. I had been messing around with it and that wasn't how it was saved. Here is how it looks:

Code: Select all
<VirtualHost *:80>
   ##ServerAdmin postmaster@dummy-host.localhost
    DocumentRoot "C:/web/projects/abba/web"
    ServerName development.abba.laptop
    ServerAlias laptop.abba
    ErrorLog "C:/web/logs/abba/error.log"
    CustomLog "C:/web/logs/abba/access.log" combined
   <Directory "C:\web\projects\abba\web">
      Order allow,deny
      Allow from all
   </Directory>
</VirtualHost>


I just tried it from another machine, and it works; however, it doesn't work from the local machine
sean.rowe
 
Posts: 2
Joined: 24. August 2009 08:37

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 133 guests