How can I host multiple websites on a WAMP server?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kufu
    New Member
    • Jun 2010
    • 3

    #1

    How can I host multiple websites on a WAMP server?

    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.z zz).

    I have assigned www.website1.xxx and www2.website3.z zz 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:

    Code:
    <virtualhost *:80>
    ServerName website1.xxx
    ServerAlias www.website1.xxx
    DocumentRoot c:/wamp/www/Folder1
    </virtualhost>
    
    <virtualhost *:80>
    ServerName website3.zzz
    ServerAlias www2.website3.zzz
    DocumentRoot c:/wamp/www/Folder2
    </virtualhost>
    I use WAMPSERVER on Win XP with Apache 2.2.11

    Thank you!
    Last edited by Niheel; Jun 2 '10, 10:55 AM. Reason: quick edit, edit out hello
  • Niheel
    Recognized Expert Moderator Top Contributor
    • Jul 2005
    • 2433

    #2
    Try this:

    Go to your Hosts file:
    "C:\windows\sys tem32\drivers\e tc"

    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:
    Code:
    NameVirtualHost *:80
    <virtualhost 127.0.0.1>
    ServerName website1.xxx
    ServerAlias www.website1.xxx
    DocumentRoot c:/wamp/www/Folder1
    </virtualhost>
     
    <virtualhost 127.0.0.1>
    ServerName website3.zzz
    ServerAlias www2.website3.zzz
    DocumentRoot c:/wamp/www/Folder2
    </virtualhost>
    note: 127.0.0.1 is the ip to most pc's local hosts
    niheel @ bytes

    Comment

    • kufu
      New Member
      • Jun 2010
      • 3

      #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!

      Comment

      • Niheel
        Recognized Expert Moderator Top Contributor
        • Jul 2005
        • 2433

        #4
        Originally posted by kufu
        Is taking me to the root of www (c:/wamp/www/) for both adresses...

        Why must make the modifications in the Hosts file?

        Thanks!
        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)
        Code:
        NameVirtualHost *:80
        <virtualhost 127.0.0.1>
        ServerName website1.xxx
        ServerAlias www.website1.xxx
        DocumentRoot "c:/wamp/www/Folder1"
        <Directory "c:/wamp/www/Folder1">
        allow from all
        order allow,deny
        AllowOverride All
        </Directory>
        DirectoryIndex index.html index.php
        </virtualhost>
         
        <virtualhost 127.0.0.1>
        ServerName website3.zzz
        ServerAlias www2.website3.zzz
        DocumentRoot "c:/wamp/www/Folder2"
        <Directory "c:/wamp/www/Folder2">
        allow from all
        order allow,deny
        AllowOverride All
        </Directory>
        DirectoryIndex index.html index.php
        </virtualhost>
        niheel @ bytes

        Comment

        • Niheel
          Recognized Expert Moderator Top Contributor
          • Jul 2005
          • 2433

          #5
          Also, don't forget to restart all services on your wamp server after making changes! Important step.
          niheel @ bytes

          Comment

          • kufu
            New Member
            • Jun 2010
            • 3

            #6
            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...

            Comment

            Working...