How to create, setup and enable the local virtual host in XAMPP Server on Windows 10

Many developers start web development in their local surround and when the work is done, they migrate their site to a live environs. The local setup provides a flexible development environment for experimenting the new techniques and most importantly managing the project code is a uncomplicated matter. If y’all are working with WordPress, setting up virtual hosts and XAMPP stack is a straightforward task.

XAMPP stack provides you lot a local platform where y’all can install and run your WordPress sites right from your Desktop/Mac. The stack supports the same components as the actual web server and it ensures that when the time comes to take the project live, the database(s) and whole website (s) could be moved hands without any hassle.

In this tutorial, I am going to demonstrate how you can set up and configure virtual hosts for WordPress websites with XAMPP running on Windows ten. I am assuming that yous already have XAMPP and WordPress installed on your Windows ten. If you are interested in setting up a new WordPress site on XAMPP, we have created a detailed guide that goes into the details of installing and running up a WordPress site on XAMPP.

  • What is a Virtual Host?
  • Create Virtual Host
  • Configure WordPress Site URL

What is a Virtual Host?

A virtual host is used for hosting multiple domain names on a unmarried server. This means different websites share the same server and utilities for their desired projection. There are many advantages when you use the virtual host concepts in a live environment and various big-scale companies follow the same principle to provide low-cost spider web hosting for their customers. The best example would be shared hosting.

At that place are three types of virtual hosts; name, IP, and port-based.

In proper name-based, you lot tin can host multiple websites on the same server IP.

Popular:   Difference Between User Experience and Design

In IP-based, each website uses a unique IP address.

In Port-Based, different websites host on a common IP accost simply distinguish on the basis of the unique port number.

Managed WordPress Hosting Starting From $10/Month

Get rid of all the hosting complexities, and savor Cloudways’ quick ane-click solutions.

Create Virtual Host

In this commodity, I’m creating a virtual host in a local environment to work around unlike WordPress projects.

So, let’s become started!

Starting time, yous need to navigate to
D:\xampp\apache\conf\extra
or wherever your XAMPP files are located. In my case, my XAMPP file is located in drive D.

location of xampp vhost file

Then, edit
httpd-vhosts.conf with whatever text editor. In my example, I am using Notepad++.

edit httpd vhosts file

The file looks something like this:

httpd vhost conf file

Now, paste the following code at the terminate of the file text/lawmaking:

<VirtualHost *:80>  DocumentRoot "D:\xampp\htdocs\testing"  ServerName farhan.cw  <Directory "D:\xampp\htdocs\testing">  </Directory>  </VirtualHost>

In the to a higher place code:

  • VirtualHost:
    Most spider web servers employ port 80 as their default port. However, you lot 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 “testing”.
  • ServerName: Information technology is the URL for our virtual host.
  • Directory:
    It is the directory of our virtual host.

Now, become to
Windows > Search > Run
and paste the following line:

C:\Windows\System32\drivers\etc\hosts

host file location windows 10

Side by side, open the Host file in your text editor and add the following line in the Host file.

127.0.0.i      farhan.cw

edit host file in windows 10

Once you are done, you need to restart Apache and MySQL from the XAMPP control console and bank check whether
http://localhost/testing
opens up in your browser.

restart apache

You can see that the domain has been changed successfully and a 500 internal server error appears for your previous URL (http://localhost/testing).

Popular:   How to Setup OpenVPN for Android | OpenVPN Server Configuration Correctly!

checking URL

Adjacent, nosotros need to change the site URL of our WordPress and therefore, we need to access the database.

Configure WordPress Site URL

At this point, I am assuming that yous have a WordPress website set upwards.

Now, it’s fourth dimension to modify the database URL (a very important step to configure virtual host).

For this, open your browser and go to
http://localhost/phpmyadmin/
and select your database. In my case, it is “testing”.

And then open up wp_options and click edit the site URL from http://localhost/testing/ to http://farhan.cw, and home URL from http://localhost/testing to http://farhan.cw.

change wordpress site url

Restart Apache and visit your virtual host URL, in our case information technology’s “farhan.cw” and check whether the domain has been set up successfully.

restart apache

Since the setup of Virtual Hosts for WordPress Website is done, here is what the final results would look like:

xampp virtual host

Terminal Words

That’due south it! I hope you accept a clear idea of setting upwardly Virtual Hosts for WordPress with XAMPP running on Windows 10. If you have whatever queries or suggestions, feel free to ask me in the comment section below.

Q. What is a virtual host in XAMPP?

In XAMPP, a virtual host is the name given to the localhost so that the programmer can hands admission assets without the result of cleaved links or similar issues. A XAMPP installation can have multiple virtual hosts.

Q. How do I add multiple virtual hosts to XAMPP Windows ten?

Adding multiple virtual hosts to XAMPP for Windows 10 is a iv-step process.

ane. Create private folders for the virtual hosts in the htdocs folder.
ii. Edit httpd-vhosts.conf to include information (including hostname, document root, and server name) well-nigh each virtual host.
3. Edit hosts file to include the IP address (usually 127.0.0.ane) and the name of the virtual hosts.
iv. Restart XAMPP and access each virtual host to test the success of the process.

Popular:   The Best Modded Minecraft Setup That You Can Use On Any Server

Q. How exercise I change my domain name from localhost in XAMPP?

Changing the domain name from localhost requires first editing the local hosts file to include the new domain name and the IP address of localhost (127.0.0.1). Next, edit httpd-vhosts.conf file to include the new domain information (hostname, document root, and server proper noun). Finally, restart XAMPP and then access the new domain in the browser.

Q. How does a virtual host work?

A virtual host emulates the functionality of a live server and provides a like directory structure and database connectivity. You can accept multiple virtual hosts at your local development car, each hosting different websites (or versions of a website). If you wish, you can besides connect the virtual host to a alive domain to farther test the functionality of the projection.

Share your stance in the comment section.
COMMENT NOW

Share This Article

Customer Review at

“Beautifully optimized hosting for WordPress and Magento”

Arda Burak [Agency Owner]

Farhan Ayub

Farhan is a community manager at Cloudways. He loves to work with WordPress and has a passion for web development. By and large, he spends his time interacting with the people in the WordPress community. Apart from his work life, Farhan spends his fourth dimension gaming and playing sports. Experience free to contact him at [electronic mail protected]

How to create, setup and enable the local virtual host in XAMPP Server on Windows 10

Source: https://www.cloudways.com/blog/configure-virtual-host-on-windows-10-for-wordpress/