Configure multiple websites in XAMPP

Source: Internet
Author: User
: This article describes how to configure multiple websites in XAMPP. For more information about PHP tutorials, see. XAMPP virtual host configuration, bind multiple domain names to access the local site
XAMPP sometimes requires some top-level domain name access methods to access your local project, that is, the virtual host configuration. in this case, you need to configure the virtual host and bind a domain name to your Directory, bind multiple domain names for access.
In Mac, MAMP has been used to build a local php environment because of its powerful combination configuration and convenient UI operations. Because the company's computer is Windows, sometimes it is necessary to build a php environment to debug some small things for your work. because it is only a small application, it is unnecessary to build a local WAMP environment, there are still a lot of online WAMP environment integration packages, such as PHPNow, WampServer, PHPStudy, AppServ, and EasyPHP, as well as the UniServer that I have been using, it's dazzling. I don't know the reason why I didn't need UniServer later. UniServer is very powerful and worthy of recommendation. but then I switched to XAMPP because it is also very powerful and has more than MB of file packages, of course you can download the Lite version, but the file size is several times larger than that of the UniServer, probably because it is large, and then I switched to XAMPP.
Sometimes you need some top-level domain name access methods to access your local project files instead of directories. in this case, you need to configure the virtual host, bind a domain name to your Directory (you can modify the hosts file to bind any domain name, such as www.a.com or localdemo ).
Assume that you have two directories:/xampp/htdocs/a and/xampp/htdocs/B.
Now you want to access the/xampp/htdocs/a directory corresponding to www.a.com during local testing, and access the/xampp/htdocs/B Directory corresponding to www. B .com.
You can bypass Apache configuration because XAMPP only integrates environment integration packages such as APache to implement multiple domain names through Apache configuration.
Although many methods are found on the Internet, the information on the Internet is Reprinted and reprinted. I doubt whether the verification is correct or not. The following method is tested by myself. if you still cannot debug local multi-domain names according to my configuration, it may be because your XAMPP version is inconsistent with mine. You can comment on me below and I will give you a one-by-one answer. The following configuration is for XAMPP Windows 1.7.1.
1. first modify the hosts file under the WINDOWS \ system32 \ drivers \ etc directory of drive C, open it in notepad, and add:

(It is added before the end of the file)
127.0.0.1 www.a.com
127.0.0.1 www. B .com
2. open xampp \ apache \ conf \ httpd. conf file, search for "Include conf/extra/httpd-vhosts.conf", make sure there is no # annotator before, that is, ensure that the vhosts virtual host configuration file is introduced.
The httpd-vhosts.conf is turned on, the default httpd. conf default configuration is invalid (make sure that the VM configuration is also enabled in the httpd-vhosts.conf file, see Article 3rd), the domain name accessing this IP will all point to vhosts. the first VM in conf. (Note: This is the first one. for details, refer to 4th)
3. set in the virtual host setting file xampp \ apache \ conf \ extra \ httpd-vhosts.conf:
Cancel NameVirtualHost *: # Before 80, so that vhosts. conf is enabled. the default httpd. conf configuration is invalid by default. The VM configuration will only be set in the httpd-vhosts.conf.

DocumentRoot/xampp/htdocs/
ServerName www.a.com


DocumentRoot/xampp/htdocs/B
ServerName www. B .com

4. after setting 3rd entries, you will find that accessing localhost directly points to the path of set a. This issue is explained in article 2nd. That is, after vhosts is enabled, the default httpd configuration will become invalid, and the default access will point to the first setting in vhosts. In this case, you need to configure the localhost directory.

DocumentRoot/xampp/htdocs/
ServerName localhost

Now, the XAMPP virtual host is set up. accessing localhost is still the help guide of XAMPP. accessing www.a.com will point to the bound a directory, and accessing www. B .com will point to the bound B Directory.
--------------------------------------------------------------------------------
Instance reference:
XAMPP adds VirtualHost to support multiple sites
In the c: \ xampp \ apache \ conf \ extra \ httpd-vhosts.conf file add the following content:
NameVirtualHost *: 80

DocumentRoot "E:/php/wordpress"
ServerName wordpress

(This section must be added, otherwise it cannot be accessed)

Options Indexes FollowSymLinks between Des ExecCGI
AllowOverride All
Order allow, deny
Allow from all

(This section sets back the default access to localhost, which must be placed later)

DocumentRoot "D:/xampp/htdocs /"
ServerName localhost

Add the following content to the hosts file in the C: \ WINDOWS \ system32 \ drivers \ etc directory:
127.0.0.1 wordpress
Put the file httpd-vhosts.conf:
# NameVirtualHost *: 80
Just remove #

The preceding section describes how to configure multiple websites in XAMPP, including related content. if you are interested in the PHP Tutorial.

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: info-contact@alibabacloud.com 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.