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 127.0.0.1 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>

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

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

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.

link|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
feedback

2 Answers

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>

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

# etc

and you only need:

127.0.0.1    site.local

in your hosts-file.

link|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
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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