Wamp Virtual host Set up in Windows

Wamp Virtual host Set up in Windows

Virtual host..What is it ? Why we have to use if ? How to setup Virtual host in Windows, using Wamp ? At first when we start developing web applications in PHP we use the URL of the format localhost/www in our browser. We place our web application files inside the folder www folder. Virtual host allows you to use a proper URL for your web application.
Why we should use Virtual host ..?
The reasons for forcing the use Virtual hosts are,
It make URL’s much cleaner. – localhost/website vs website.app (or website.local). You can give your own .com/.app/.true/whatever
It makes permissions mush easier – You can restrict access for a single host.
Applications needs a “.” (.com/.in must for some apps like magento) can easily develop with Virtual host.

Ok. Let’s start, Wamp Virtual host Set up in Windows.
Steps:
1.) First, Include the Virtual Host Configuration File in Apache
Open Apache configuration file located in C:\wamp\bin\Apache\conf\httpd.conf.
Search for “LoadModule vhost_alias_module” and find it.
Uncomment the LoadModule vhost_alias_module modules/mod_vhost_alias.so. ( So, it can look up for virtual host configurations and activate it).
Search for “Virtual Hosts”
Uncomment the Include conf/extra/httpd-vhosts.conf.
Now, Save and close the httpd.conf file.

2.) Update Virtual Host Configuration File
Open Apache Virtual Hosts (vhost) configuration file from C:\wamp\bin\Apache\conf\extra\httpd-vhosts.conf.
Now, we have to add a new vhost. Just examine the file, you will get an idea. If you can’t under start, visit Apache project’s documentation.
Now, Save and close the httpd-vhosts.conf file.

3.) Update Windows Hosts File
Open your Windows hosts file located in C:\Windows\System32\drivers\etc\hosts.Add your website name.
Now, Save and close the hosts file.

4.) Restart All Services in WAMP, Now you can access the URL from the browser.

Little more about Host file in Windows
When you type a URL in Browser, it will first look for in the host file. If it is not specified there, it will take it from the internet. If you specify a host 127.0.0.1 yourwebsite.com, it will search on your local machine. 127.0.0.1 means local host. Also, if you add www.google.com in your host file like this, 127.0.0.1 www.google.com, you can’t access the same URL from internet. This is because the name resolution is already done in locally.

A sample Host file and Virtual Host Configurations

1 Comment

  1. Orthotic arch supports

    Wamp Virtual host Set up in Windows – Very good info can be found on blog.

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *