Connect with Expertise | Find Experts, Get Answers, Share Insights

How can I host multiple websites on a WAMP server?

 
Join Date: Jun 2010
Posts: 3
#1: Jun 2 '10
I am new with Apache and I want to try this:

On a server (IP xx.xx.xx.xx) I would like to host multiple websites (www.website1.xxx, www.website2.yyy, www2.website3.zzz).

I have assigned www.website1.xxx and www2.website3.zzz the IP xx.xx.xx.xx.

In the www folder of the server I have Folder1 (for website1) and Folder2 (for website3).

Now, the problem is that no mather what adress you try to acces, the result is index from Folder1.
The code is as follows:

Expand|Select|Wrap|Line Numbers
  1. <virtualhost *:80>
  2. ServerName website1.xxx
  3. ServerAlias www.website1.xxx
  4. DocumentRoot c:/wamp/www/Folder1
  5. </virtualhost>
  6.  
  7. <virtualhost *:80>
  8. ServerName website3.zzz
  9. ServerAlias www2.website3.zzz
  10. DocumentRoot c:/wamp/www/Folder2
  11. </virtualhost>
I use WAMPSERVER on Win XP with Apache 2.2.11

Thank you!

Niheel's Avatar
E
M
C
 
Join Date: Jul 2005
Location: Portland, OR, United States
Posts: 1,306
#2: Jun 2 '10

re: How can I host multiple websites on a WAMP server?


Try this:

Go to your Hosts file:
"C:\windows\system32\drivers\etc"

Add this:
127.0.0.1 website1.xxx
127.0.0.1 website3.zzz
127.0.0.1 www.website1.xxx
127.0.0.1 www.website3.zzz

In your conf file use this:
Expand|Select|Wrap|Line Numbers
  1. NameVirtualHost *:80
  2. <virtualhost 127.0.0.1>
  3. ServerName website1.xxx
  4. ServerAlias www.website1.xxx
  5. DocumentRoot c:/wamp/www/Folder1
  6. </virtualhost>
  7.  
  8. <virtualhost 127.0.0.1>
  9. ServerName website3.zzz
  10. ServerAlias www2.website3.zzz
  11. DocumentRoot c:/wamp/www/Folder2
  12. </virtualhost>
note: 127.0.0.1 is the ip to most pc's local hosts
 
Join Date: Jun 2010
Posts: 3
#3: Jun 2 '10

re: How can I host multiple websites on a WAMP server?


Is taking me to the root of www (c:/wamp/www/) for both adresses...

Why must make the modifications in the Hosts file?

Thanks!
Niheel's Avatar
E
M
C
 
Join Date: Jul 2005
Location: Portland, OR, United States
Posts: 1,306
#4: Jun 2 '10

re: How can I host multiple websites on a WAMP server?


@kufu
It's the only way those domains will propogate to your local host. Make sure that those folders exist and that there are valid index.html files in there.

Try this: (added .htacces support and DirectoryIndex so it points to index.html file)
Expand|Select|Wrap|Line Numbers
  1. NameVirtualHost *:80
  2. <virtualhost 127.0.0.1>
  3. ServerName website1.xxx
  4. ServerAlias www.website1.xxx
  5. DocumentRoot "c:/wamp/www/Folder1"
  6. <Directory "c:/wamp/www/Folder1">
  7. allow from all
  8. order allow,deny
  9. AllowOverride All
  10. </Directory>
  11. DirectoryIndex index.html index.php
  12. </virtualhost>
  13.  
  14. <virtualhost 127.0.0.1>
  15. ServerName website3.zzz
  16. ServerAlias www2.website3.zzz
  17. DocumentRoot "c:/wamp/www/Folder2"
  18. <Directory "c:/wamp/www/Folder2">
  19. allow from all
  20. order allow,deny
  21. AllowOverride All
  22. </Directory>
  23. DirectoryIndex index.html index.php
  24. </virtualhost>
Niheel's Avatar
E
M
C
 
Join Date: Jul 2005
Location: Portland, OR, United States
Posts: 1,306
#5: Jun 2 '10

re: How can I host multiple websites on a WAMP server?


Also, don't forget to restart all services on your wamp server after making changes! Important step.
 
Join Date: Jun 2010
Posts: 3
#6: Jun 2 '10

re: How can I host multiple websites on a WAMP server?


No change...

But... if I try to access the addresses from local machine, I get only Folder1. If accessed from internet, I get /www index.

EDIT: after each change I restart the Apache server...
Reply

Tags
apache, hosting, server, virtualhost