Setup a Virtual Host on WAMP 3

Setting up a virtual host provides several benefits:

  1. Virtual Hosts make URL cleaner
  2. Virtual Hosts make permissions easier
  3. Some applications require a “.” in the URL like Magento.
So, let's setup a virtual host (vhost) in WAMP 3.

Step 1: Change Virtual Host Configuration File in Apache
  • Open your Apache configuration file located in C:\wamp64\bin\apache\apache2.4.37\conf\httpd.conf
  • Search LoadModule vhost_alias_module and un-comment the line LoadModule vhost_alias_module modules/mod_vhost_alias.so
  • Search Virtual Hosts and un-comment the line Include conf/extra/httpd-vhosts.conf
  • Save and close the httpd.conf file
Step 2: Update Virtual Host Configuration File
  • Open your vhost configuration file located one directory down from the Apache configuration file directory in C:\wamp64\bin\apache\apache2.4.37\conf\extra\httpd-vhosts.conf
  • Add the configuration for your new vhost like below
#Your new site
<VirtualHost *:80>
  ServerName local.newsite.com
  ServerAlias www.local.newsite.com
  DocumentRoot "${INSTALL_DIR}/www/newsite"
  <Directory "${INSTALL_DIR}/www/newsite">
    AllowOverride all
Order Allow,Deny
Allow from all
  </Directory>
</VirtualHost>
  • Save and close the httpd-vhosts.conf file.
Step 3: Update Your Windows Hosts File
  • Open your Windows hosts file located in C:\Windows\System32\drivers\etc\hosts.
  • Add a new site. 
127.0.0.1 local.newsite.com
::1 local.newsite.com
  • Save and close the hosts file.
  • Resart All Services in WAMP
  • Open local.newsite.com on your browser
Enjoy....

Comments

Popular posts from this blog

Creating Protected routes in ReactJS

Redirect http to https in codeigniter