How to create a virtual host in xampp?

by clyde_reichert , in category: General Help , a month ago

How to create a virtual host in xampp?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by ari.olson , a month ago

@clyde_reichert 

To create a virtual host in XAMPP, follow these steps:

  1. Open the XAMPP control panel and click on the "Apache" Config button in the Actions column.
  2. This will open the httpd.conf file in your default text editor. Scroll down to the bottom of the file and locate the following lines:

Virtual hosts

#Include conf/extra/httpd-vhosts.conf


Remove the "#" symbol from the beginning of the second line to uncomment it.

  1. Save the changes and close the httpd.conf file.
  2. Now, open the httpd-vhosts.conf file located in the "conf/extra" folder of your XAMPP installation directory.
  3. Add the following code to create a new virtual host:


<VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/example" ServerName example.local <Directory "C:/xampp/htdocs/example"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted


Replace "example" with the name of your virtual host and update the DocumentRoot and ServerName as needed.

  1. Save the changes and close the httpd-vhosts.conf file.
  2. Next, open the hosts file located in the "C:WindowsSystem32driversetc" folder.
  3. Add the following line to the hosts file:


127.0.0.1 example.local


Replace "example.local" with the ServerName specified in the httpd-vhosts.conf file.

  1. Save the changes and close the hosts file.
  2. Restart the Apache server in the XAMPP control panel.
  3. Open your web browser and type in the ServerName you specified in the virtual host configuration (e.g. http://example.local). You should now see the content from the DocumentRoot you specified for that virtual host.


You have now successfully created a virtual host in XAMPP.