Home  >  Article  >  Backend Development  >  How Do I Set Up Virtual Hosts on XAMPP?

How Do I Set Up Virtual Hosts on XAMPP?

Linda Hamilton
Linda HamiltonOriginal
2024-10-27 07:00:29290browse

How Do I Set Up Virtual Hosts on XAMPP?

Creating Virtual Hosts on XAMPP: A Detailed Walkthrough

This article aims to provide a comprehensive guide to creating virtual hosts on XAMPP. Despite the prevalence of this question, some users may still encounter difficulties.

Steps involved

1. Configure hosts file:

Navigate to: "C:WINDOWSsystem32driversetc" and open the "hosts" file.
Add the following lines:

127.0.0.1       localhost
127.0.0.1       test.com
127.0.0.1       example.com

2. Configure httpd-vhosts.conf:

Navigate to: "xamppapacheconfextrahttpd-vhosts.conf" and add the following:

<VirtualHost *:80>
    DocumentRoot C:/xampp/htdocs/test/
    ServerName www.test.com
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot C:/xampp/htdocs/example/
    ServerName www.example.com
</VirtualHost>

3. Enable Virtual Hosts in httpd.conf:

Navigate to: "C:xamppapacheconfhttpd.conf." Locate the "Supplemental configuration" section and uncomment the following line:

#Virtual hosts
Include conf/extra/httpd-vhosts.conf

4. Restart XAMPP

Restart XAMPP Control Panel to apply the changes.

5. Test Virtual Hosts

In a web browser, navigate to:

www.example.com or www.test.com

Note:

If you encounter errors while restarting Apache, check the error logs in "C:xamppapachelogs" and verify that the syntax of your virtual host configuration files is correct.

The above is the detailed content of How Do I Set Up Virtual Hosts on XAMPP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn