Setting Virtual Host Using Wamp
Step 1: -
Download and install WAMP, then start the program
Go to "C:/Windows/System32/drivers/etc" and open the "hosts" file in Notepad.
At the bottom of the hosts file, below all the other text, add a new line with the following: 127.0.0.1 mysite.local #My Test Site
(# symbol is used for comments)
Open "C:/wamp/bin/apache/Apache2.2.21/conf/" (your Apache version number may be different)- There will be 2 files - one called "httpd.conf", and one called "httpd.conf.build", Open "httpd.conf".
There will be entry of "# Virtual hosts", uncomment (remove the hashtag [#]) the line below it: "Include conf/extra/httpd-vhosts.conf".This tells Apache to include the file "httpd-vhosts.conf" (the file where we set our virtual hosts) when configuring its settings.
Go to "C:/wamp/bin/apache/Apache2.2.21/conf/extra" and open the file "httpd.vhosts.conf".
We need to give Apache permission to look in our "Projects" folder for websites. At the bottom of the page, below all the other text, add the following:
After the directory code you just added, add:
- The DocumentRoot should be the path to the folder where your site lives, and the ServerName should match the domain you entered in your hosts file in Step 3.- Important: The DocumentRoot must be inside the directory that you gave Apache permission to access in Step 7.Save the file now
Click on the green WAMP icon in your toolbar and select "Restart all Services", then wait for the icon to turn back to green.
Open your browser and navigate to "mysite.local", or whatever your domain name is. You should see the test page you created in Step 1.
If you're going to be working on sites with custom .htaccess files, you'll need to set AllowOverride in Step 7: