How to Create Virtual Host with Wamp Server

Hello Dev, are you struggling to create virtual hosts on your Wamp Server? Don’t worry, in this article we will guide you through the process of creating virtual hosts on your Wamp Server step by step.

What is Virtual Host?

Before we dive into the steps of creating virtual hosts, let’s understand what virtual hosts are. Virtual Host is an Apache feature that allows you to host multiple websites on a single server by using different domain names.

For example, if you have two websites, website1.com and website2.com, you can host both these websites on a single server using virtual hosts.

Step 1: Configuring the Virtual Hosts File

The first step in creating virtual hosts on your Wamp Server is to configure the Virtual Hosts file. To access the Virtual Hosts file, follow the steps below:

  1. Open the Wamp Server installation directory (usually C:\wamp64).
  2. Locate the Apache\conf\extra directory and open the httpd-vhosts.conf file.

Once you have opened the file, you will see the default settings for virtual hosts. You can add your virtual hosts to this file.

Step 2: Creating a Folder for Your Virtual Host

The next step is to create a folder for your virtual host. You can create this folder anywhere on your computer, but we recommend creating it in the C:\wamp64\www directory.

To create a folder, follow the steps below:

  1. Open the C:\wamp64\www directory.
  2. Right-click and select New Folder from the context menu.
  3. Name the folder after your virtual host.

Step 3: Adding Your Virtual Host to the Virtual Hosts File

Once you have created a folder for your virtual host, you need to add it to the Virtual Hosts file. To add your virtual host, follow these steps:

  1. Open the httpd-vhosts.conf file.
  2. Add the following code to the bottom of the file:
Code

DocumentRoot “C:/wamp64/www/your-virtual-host”
ServerName your-virtual-host.dev

AllowOverride All
Require all granted

Replace “your-virtual-host” with the name of your virtual host folder.

Step 4: Restarting your Wamp Server

Once you have added your virtual host to the Virtual Hosts file, you need to restart your Wamp Server for the changes to take effect. You can restart your Wamp Server by following these steps:

  1. Right-click on the Wamp Server icon in the system tray.
  2. Select Restart All Services from the context menu.
Step 5: Editing Your Hosts File

The final step is to edit your Hosts file to map your domain name to your virtual host. To edit your Hosts file, follow these steps:

  1. Open the C:\Windows\System32\drivers\etc directory.
  2. Open the hosts file using Notepad.
  3. Add the following line to the bottom of the file:
Code
127.0.0.1 your-virtual-host.dev

Replace “your-virtual-host” with the name of your virtual host folder.

READ ALSO  Check the Hosting Server of Your Website: A Comprehensive Guide for Dev

Frequently Asked Questions

1. What is a virtual host?

A virtual host is an Apache feature that allows you to host multiple websites on a single server by using different domain names.

2. Where is the Virtual Hosts file located on Wamp Server?

The Virtual Hosts file is located in the Apache\conf\extra directory in your Wamp Server installation folder.

3. How do I restart my Wamp Server?

You can restart your Wamp Server by right-clicking on the Wamp Server icon in the system tray and selecting Restart All Services from the context menu.

4. Can I create multiple virtual hosts on my Wamp Server?

Yes, you can create multiple virtual hosts on your Wamp Server by adding the necessary code to the Virtual Hosts file.

5. Do I need to edit my Hosts file after creating a virtual host?

Yes, you need to edit your Hosts file to map your domain name to your virtual host.

Congratulations! You have successfully created a virtual host on your Wamp Server. You can now host multiple websites on a single server using different domain names.