Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I apologize, but this is difficult to figure out.

I am running Apache 2.2, this is on a Windows box, my own home PC for development use only. Windows XP Pro SP3.

I have five sites that I need to create virtual hosts for. Each has the same URL but different IP addresses and different folders.

I have the URL + port pointing to in the hosts file, but can't get the syntax correct for the virtual hosts.

<VirtualHost site.local:1>
DocumentRoot "C:/www/1"
ServerName site.local:1

<VirtualHost site.local:2>
DocumentRoot "C:/www/2"
ServerName site.local:2

<VirtualHost site.local:3>
DocumentRoot "C:/www/3"
ServerName site.local:3

And no, these are not real ports I plan to use, just to give you a basic example of the folder structure and URL structure.

I put a standard index.html in one of the folders and then I try to go to that URL and it always times out.

So I want to know the correct syntax and how to do this in the future, because this part seems to be always confusing.

share|improve this question
You have not included enough information to help you: Are there any errors in your Apache log files? – voretaq7 Mar 21 '11 at 19:23
Why are you using different ports ? – Iain Mar 21 '11 at 19:33
Just the way the client requested. Not my preference. – crosenblum Mar 21 '11 at 20:34
up vote 0 down vote accepted

If you want to have VirtualHosts with the same ServerName but on different ports, you're after the following Apache config:

<VirtualHost *:1111>
    ServerName site.local
    DocumentRoot "C:/www/1"

<VirtualHost *:2222>
    ServerName site.local
    DocumentRoot "C:/www/2"

# etc

and you only need:    site.local

in your hosts-file.

share|improve this answer
They are the same ip, same url, different ports. – crosenblum Mar 21 '11 at 18:44
Your question says "Each has the same url, but different ip addresses"; I've updated my answer to reflect your comment. – nickgrim Mar 21 '11 at 19:25

See my comment on the original question -- Log entries would be extremely helpful in diagnosing your problem.

Also as a wild shot in the dark, please make sure that you have Listen directives for each port you want to use in your Apache configuration.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.