Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Apache virtual hosting

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have an Apache 2.0 running on localhost.
My default DocumentRoot is set to:
DocumentRoot "H:/apache2.0/Apache2/htdocs"

I'm trying to use virtual hosting (for testing), and I've got the following settings:
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1>
DocumentRoot "c:/mywebpage"
ServerName localhost
</VirtualHost>
Now when I type "http://localhost" in my browser, apache still serves the index page from the default DocumentRoot !
Why's this ?

Thanks everyone
Dennis
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you have a conflict between the virtual host and the default host - you're giving them both the same URL!
A more realistic setup would be to do:
<VirtualHost 127.0.0.1:8080>
in order to see the alternate (virtual) host as http://localhost:8080.
This requires that you tell Apache it's OK to serve out of port 8080 in addition to port 80.
The other use of VirtualHost is to access under a different domain, like so:
<VirtualHost www.mydomain.com>
<VirtualHost info.mydomain.com>
<VirtualHost www.otherdomain.net>
Which provides 4 total host URLs - the default +
http://www.mydomain.com, http://info.mydomain.com, and http://www.otherdomain.net.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cool .. thanks a lot !
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic