Setup a Virtual Host on WAMP 3
Setting up a virtual host provides several benefits:
- Virtual Hosts make URL cleaner
- Virtual Hosts make permissions easier
- 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
Post a Comment