How Do I Set Up Virtual Hosts on XAMPP?

Linda Hamilton
Release: 2024-10-27 07:00:29
Original
289 people have browsed it

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
Copy after login

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>
Copy after login

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
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!