Setting up virtual host on WAMP server
0
/
2371
Why setup a virtual host on WAMP server
- It gives simpler, cleaner and easy to remember URLs like we have for public websites.
- Mapping permissions to different IP addresses becomes easier.
3 simple steps to setup virtual host on WAMP
- First step is to edit httpd.conf file which is located in wamp\bin\apachex.x.xx\conf directory and search for vhost_alias and Virtual hosts and make sure the below lines following each of those options are commented:LoadModule vhost_alias_module modules/mod_vhost_alias.so & Include conf/extra/httpd-vhosts.conf.This is shown in screenshot below:
- Second step is to go to C:\windows\system32\drivers\etc directory and add the following lines to your hosts file: 127.0.0.1 sydney-home 127.0.0.1 sydney-home.com 10.0.0.28 sydney-home 10.0.0.28 sydney-home.com 127.0.0.1 sydney-home.local 127.0.0.1 www.localhost.com 127.0.0.1 localhost 127.0.0.1 localhost.com In this case, sydney-home is the name of my virtual host. Please replace it accordingly as per your virtual host name chosen by you.
- The last step is to edit the httpd-vhosts.conf file and add the below code to it:- <VirtualHost *:80> ServerAdmin webmaster@sydney-home.com DocumentRoot “c:/wamp/www/” ServerName sydney-home.local ServerAlias www.sydney-home.local ErrorLog “logs/sydney-home.com-error.log” CustomLog “logs/sydney-home.com-access.log” common <Directory “c:/wamp/www/”> Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Deny from all Allow from 127.0.0.1 ::1 </Directory> </VirtualHost> at the end of the file.This file can be found at location : wamp\bin\apache\apachex.xx.xx\conf\extra\httpd-vhosts.conf.