How to Set up multiple websites in XAMPP.

Source: Internet
Author: User
Tags tld

XAMPP is a very convenient debugging environment for local Apache + PHP + MySQL. you can install and test WordPress and other blogs and forums locally.ProgramVery convenient. Today, we will introduce how to use XAMPP to install multiple websites locally.

In general, we only need to put the website program under the XAMPP/htdoc directory, and then enter the IP address http: // the browser or enter the Domain Name HTTP: // localhost. However, we can only use one program to create one website. If we want to test different programs, such as a WordPress website and a discuz! And a shopex online shop. This articleArticleTo introduce how to add multi-site support in XAMPP, so that you can easily install multiple websites.

For example, we want to install two local test domain names, www. ABC. TLD and www. XYZ. TLD, pointing to the ABC. TLD and XYZ. TLD folders under the htdoc directory respectively. TLD is the abbreviation of top-level domain name the top domain. If you like, you can also use top-level domain names such as and TLD is used here to avoid conflicts with real domain names.

1. Set domain name resolution in the hosts file

Like normal domain names, these two domain names do not exist, and we also need to resolve them; otherwise, the browser does not know where to find the server. We will use the local hosts file to solve this problem. This file is used to specify the ing between the domain name and IP address. When you want to enter a website in the browser for access, the browser will send a domain name resolution request to the DNS server on the local network. However, before sending a resolution request, you must first check whether there is a resolution record in the hosts file. If there is a record for the domain name, you can use this record for access. Therefore, this file is equivalent to a domain name resolution cache file.

The hosts file is saved in the C: windowssystem32driversetc directory and has no extension. You can use a text editor (Notepad, emeditor, ultraedit, and so on) to open and edit it. For Windows Vista or Windows 7, you must first use the administrative permission to open notepad.

Then, we add two lines of domain name resolution records at the end of the file, with one domain name per line. The front is an IP address, space is separated by spaces or tabs, followed by a Domain Name: www. ABC. TLD www. XYZ. TLD

As shown in:

Then save the hosts file.

2. Add two folders under the htdocs directory

In the XAMPP/htdocs directory, we create two folders named www. ABC. TLD and www. XYZ. TLD respectively. Here, the name of the file directory is set to the domain name format for easy differentiation, not mandatory; as long as the directory name and the subsequent settings are consistent.

Add an index.html file to the www. ABC. TLD directory. The content is as follows:


Add the same index.html file in the www. XYZ. TLD directory and replace ABC with XYZ.

This index.html file does not comply with the HTML specification, but is used to verify whether our multi-domain support is successful.

3. Add support for multiple domain names in Apache

Now the most important step is to pay attention. Let's bind multiple domain names to Apache to support access from multiple sites. Open the file xamppapacheconfextrahttpd-vhosts.conf with the file editor.

First find namevirtualhost *: 80; remove the annotator #. If this row does not exist, add a row by yourself.

Then add the followingCode:

& Lt; virtualhost *: 80 & gt; serveradmin postmaster@abc.tld DocumentRoot & gt;/XAMPP/htdocs/www. ABC. TLD "servername www. ABC. TLD errorlog "logs/www. ABC. tld-error.log "customlog" logs/www. ABC. tld-access.log "combined </virtualhost> <virtualhost *: 80> serveradmin postmaster@xyz.tld DocumentRoot"/XAMPP/htdocs/www. XYZ. TLD "servername www. XYZ. TLD errorlog "logs/www. XYZ. tld-error.log "customlog" logs/www. XYZ. tld-access.log "combined </virtualhost>

Save the file. Code in httpd-vhosts.conf such:

4. Restart Apache and verify multiple domain names

After the video preparation is complete, restart the apache service and re-open the browser. And enter the and in the browser, you can see the following results respectively:

After setting, enter the and separately in the browser, and different contents are displayed. If you see the same content, it means that your XAMPP supports multiple domain names. Otherwise, check from the beginning to see where the settings are wrong.

If you have any questions, please leave a message.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.