Question

I use WAMP server on my Windows machine. I want to achieve the following setup:

1) I want to create multiple folders in my wamp's 'www' directory each representing a website. 2) Add multiple entries to my host file with different ip addresses, each pointing to one of the folders in the wamp's 'www' directory.

So lets say, I create 3 folders in my wamp 'www' directory named - "site1", "site2", "site3" and add the following to my host file:

127.0.0.1 site1.local 127.0.0.2 site2.local 127.0.0.3 site3.local

And then I goto the url "site1.local", I can get to the folder "site1" and the same for other two as well.

My knowledge: I noticed that even if the host file is empty, going to any address in the format - "127.xx.xx.xx" where xx can be upto 99 and the last one not being 0 - will result in loading the default wamp page.

I know about setting virtual host servers in wamp through apache and addressing them to different directories.

My difficulty: I tried many different ways but any address would only straight away point to the default directory that I set in apache as the main host. I think the host file is meant to be used to point all the addresses to the same point no matter what address we add to it. (But I'm not sure...)

Please help me achieve the aforesaid setup.

Was it helpful?

Solution

Can I suggest that you try Virtual Hosts again. Here is a tutorial on how to do it in WAMPServer.

WAMPServer forum - HOWTO Create Virtual hosts

They should do exactly what you want but without the need to use different ip addresses. When setup correctly all you need to enter in the browser address bar is you desirecd site domain name i.e site2.dev and apache will switch you to the correct document root and the site will function as it is were a single site on Apache.

OTHER TIPS

you can add below configuration in your virtual host file that is located in "C:/wamp/bin/Apache/#.#.#/conf/extra/httpd-vhosts.conf" . If you want create multiple host you can replicate below configuration and give the appropriate project directory path and and your virtual host name.

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/wamp/www/phpclicks"
ServerName phpclicks.com
ServerAlias www.phpclicks.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
  <Directory "/">
        Deny from all
        Allow from 127.0.0.1 localhost ::1
    </Directory>
</VirtualHost>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top