364,032 Members | 4161 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

How can I host multiple websites on a WAMP server?

kufu
P: 3
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!
Jun 2 '10 #1
Share this Question
Share on Google+
5 Replies


Niheel
Expert Mod 100+
P: 757
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
Jun 2 '10 #2

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

Why must make the modifications in the Hosts file?

Thanks!
Jun 2 '10 #3

Niheel
Expert Mod 100+
P: 757
@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>
Jun 2 '10 #4

Niheel
Expert Mod 100+
P: 757
Also, don't forget to restart all services on your wamp server after making changes! Important step.
Jun 2 '10 #5

kufu
P: 3
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...
Jun 2 '10 #6

Post your reply

Help answer this question



Didn't find the answer to your Apache Web Server question?

You can also browse similar questions: Apache Web Server apache hosting server virtualhost