How to Setup Virtual Host in Windows

Step: 1

Create the Virtual Host

First, you need to navigate to D:wamp64binapacheapache2.4.27confextra or wherever your WAMP files are located.
Then, edit httpd-vhosts.conf with any text editor. In my case, I am using Notepad++.

<VirtualHost lawrawel.samweb.com:80>
  ServerName lawrawel.samweb.com
  #ServerAlias localhost
  DocumentRoot “${INSTALL_DIR}/www/lawrawel_sep/sam_web”
  <Directory “${INSTALL_DIR}/www/lawrawel_sep/sam_web/”>
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

#VirtualHost: Most web servers use port 80 as their default port. However, you can change the port to 8080, 8081 etc.
#DocumentRoot: The folder where files of a site will exist. In our case, the folder name is “sam_web”.
#ServerName: It is the URL for our virtual host.
#Directory: It is the directory of our virtual host.




Step: 2

Create the Host
Now, go to “C:WindowsSystem32driversetchosts”

Next, open Host file in your text editor.
Add the following line in the Host file.
127.0.0.1 lawrawel.samweb.com


Step: 3

#After you have done all the steps, restart wampserver for the configuration to be set.

#Open a browser and navigate to “lawrawel.samweb.com” You should see your website.

That’s it you have a running virtual host.

Leave a Reply