Meera
Meera

Reputation: 149

Hosting more than one site in a wamp server

I have two different sites and i want to host both of them through wamp server for example, my first site is http://one.gov.ae and the second one is http://two.gov.ae

what I want is when I type the first site it should open the index for the first one and i when i type the second one it should open the second site.

but whatever I type it open the index for the first one

however I add both sits in httpd-vhosts.con and uncomment the following line in http.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

So anyone can tell me what I can do in such situation

here is my httpd-vhosts.conf code

<VirtualHost 172.20.10.121:80>
   # ServerAdmin admin@localhost
     DocumentRoot "C:/wamp/www"
     ServerName localhost
   # ServerAlias www.dummy-host.localhost
   # ErrorLog "logs/dummy-host.localhost-error.log"
   # CustomLog "logs/dummy-host.localhost-access.log" common
</VirtualHost>

<VirtualHost 172.20.10.121:8080>
   # ServerAdmin [email protected]
     ServerName meera.am.gov.ae
     DocumentRoot "c:wamp/www/meera"
     Directoryindex index.php index.html
   # ErrorLog "logs/dummy-host2.localhost-error.log"
   # CustomLog "logs/dummy-host2.localhost-access.log" common
</VirtualHost>

I comment the following in httpd file

# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<FilesMatch "^\.ht">
  #  Order allow,deny
  #  Deny from all
  # Satisfy All
</FilesMatch>

Upvotes: 2

Views: 2191

Answers (4)

vbence
vbence

Reputation: 20343

but whatever I type it open the index for the first one

So I guess your server does listen on the port 8080 too. You did not mention that part.

The problem could be that you also enabbled name based virtual hosting with something like:

NameVirtualHost *

... or

NameVirtualHost 172.20.10.121

This way Apache is identifying hosts by hostname (the Host request header). If no host is sent or no matching ServerName found in config, the first host (the default host) will handle the request.

Although instead of this port madness I strongly recommend you using name-based virtual hosts. With names like mysite.test or jopbsite.test or projectname.test etc. This way they can all listen on port 80, you have to define the ServerName for all of the hosts, enbale name based virtual hosting with one of my examples above then define your NS entries in:

c:\windows\system32\drivers\etc\hosts

file.

Edit:

ou should have something like this in your vhosts.conf:

NameVirtualHost *

<VirtualHost *>
     ServerName mysite.test

     DocumentRoot "C:/www/mysite.test"
     Directoryindex index.php index.html
</VirtualHost>

<VirtualHost *>
     ServerName theothersite.test

     DocumentRoot "C:/www/theothersite.test"
     Directoryindex index.php index.html
</VirtualHost>

Upvotes: 1

Vern
Vern

Reputation: 2413

I had this problem a while back and I found out that it was a silly mistake that I didn't do a restart on the httpd server.

You could try running this from a command prompt if you have the /bin directory linked in your PATH:

httpd -k restart

Hope it helps ! Cheers :)

Upvotes: 0

ebrandell
ebrandell

Reputation: 432

You'll need to modify your .conf to account for two separate virtual hosts.

In the below example you'll basically need to set the ServerName, ServerAlias and other variables in order to separate them.

<VirtualHost *>
    ServerAdmin [email protected]
    ServerName  www.example.org
    ServerAlias example.org

    # Indexes + Directory Root.
    DirectoryIndex index.html
    DocumentRoot /home/www/www.example.org/htdocs/
</VirtualHost>

<VirtualHost *>
    ServerAdmin [email protected]
    ServerName  www.example.com
    ServerAlias example.com

    # Indexes + Directory Root.
    DirectoryIndex index.html
    DocumentRoot /home/www/www.example.com/htdocs/
</VirtualHost>

Hope that helps. Be sure to stop Apache before modifying the .conf file and then start it again.

Upvotes: 0

David Fells
David Fells

Reputation: 6798

There are lots of detailed tutorials on this. I haven't used WAMP in a while but this is the guide I used when I did last: http://cesaric.com/?p=255

Upvotes: 0

Related Questions