How to create a virtual host in WampServer Windows 10

 WampServer is a popular software stack for Windows that provides a web development environment for Apache, MySQL, and PHP. It's a useful tool for web developers and designers who need to test their web applications in a local environment. One of the useful features of WampServer is the ability to create virtual hosts.


A virtual host is a web server that acts like a separate web server with its own domain name and IP address. It allows you to host multiple websites on a single server, making it easy to test and develop multiple projects without having to use multiple IP addresses or computers.

Here's how you can create a virtual host in WampServer Windows 10:

  1. Start WampServer: Open WampServer from the Start menu, and make sure all the services (Apache, MySQL, and PHP) are running.
  2. Edit the Apache configuration file: Open the Apache configuration file located at "C:\wamp64\bin\Apache\Apache2.4.46\conf\httpd.conf".
  3. Enable virtual host: Uncomment the following line of code by removing the # symbol: "#Include conf/extra/httpd-vhosts.conf"
  4. Edit the virtual host file: Open the virtual host file located at "C:\wamp64\bin\Apache\Apache2.4.46\conf\extra\httpd-vhosts.conf".
  5. Add a new virtual host: Add the following code to the end of the file, replacing the example.com with your desired domain name, and the path with the location of your website files:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot "C:/wamp64/www/path"
    <Directory "C:/wamp64/www/path">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

 

6. Restart Apache: Restart Apache by clicking on the WampServer icon in the system tray and selecting "Restart All Services". 
7. Edit the host file: Open the host file located at "C:\Windows\System32\drivers\etc\hosts".
8. Add a new host entry: Add the following line of code to the end of the file, replacing the example.com with your desired domain name, and the IP address with 127.0.0.1:

 

127.0.0.1 example.com

 

9. Test the virtual host: Open your web browser and enter the domain name you specified in the virtual host configuration.


In conclusion, creating a virtual host in WampServer Windows 10 is a straightforward process that can help streamline your web development workflow. By having multiple virtual hosts, you can easily test and develop multiple projects on a single server, making it a valuable tool for any web developer or designer.

Post a Comment

Previous Post Next Post