Forum Moderators: phranque
I'm having a problem with my apache setup. Basically I want to run multiple websites from my localhost server so I've set up virtualhosts on my apache conf file and in my windows hosts file. However for some reason I have found that no matter which address I put in the address bar the first website always comes up. Can someone advise me where I'm going wrong?
Here is the hosts file:
127.0.0.1 localhost
127.0.0.1 site1
127.0.0.1 site2
127.0.0.1 site3
Here is the apaache conf file:
NameVirtualHost *:80
<VirtualHost site1:80>
DocumentRoot "C:/PHP/site1"
ServerName site1
</VirtualHost>
<VirtualHost site2:80>
DocumentRoot "C:/PHP/site2"
ServerName site2
</VirtualHost>
<VirtualHost site3:80>
DocumentRoot "C:/PHP/site3"
ServerName site3
</VirtualHost>
I didn't add a virtualhost for localhost but I shouldn't think it should make any difference. I'm not sure if I need the server name and port number in the tag but it I added them because it wasn't working.
If I understand it correctly [site2...] and [site3...] should work. Can anyone help?
(Notice the notes about default or primary servers in several of the example cases)
Jim
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#####################################################################
#Site1
<VirtualHost *:80> #Home
ServerName site1
ServerAlias site1
ServerAlias site1
DocumentRoot C:\PHP\Site1
</VirtualHost>
###########################################
#HOST
<VirtualHost *:80> #Site2
ServerAdmin User@domain.com
ServerName site2
ServerAlias site2
DocumentRoot C:\PHP\Site2
</VirtualHost>
#######################
[edited by: Revelation at 9:23 am (utc) on June 25, 2007]