Configure multiple websites in XAMPP and multiple websites in xampp

Source: Internet
Author: User

[Go] configure multiple websites in XAMPP and multiple websites in xampp

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. in confFirst VM. (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.
<VirtualHost *: 80>
DocumentRoot/xampp/htdocs/
ServerName www.a.com
</VirtualHost>

<VirtualHost *: 80>
DocumentRoot/xampp/htdocs/B
ServerName www. B .com
</VirtualHost>

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.
<VirtualHost *: 80>
DocumentRoot/xampp/htdocs/
ServerName localhost
</VirtualHost>

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

<VirtualHost *: 80>
DocumentRoot "E:/php/wordpress"
ServerName wordpress
</VirtualHost>

(This section must be added, otherwise it cannot be accessed)
<Directory "E:/php/wordpress">
Options Indexes FollowSymLinks between des ExecCGI
AllowOverride All
Order allow, deny
Allow from all
</Directory>

 

(This section sets back the default access to localhost, which must be placed later)
<VirtualHost *: 80>
DocumentRoot "D:/xampp/htdocs /"
ServerName localhost
</VirtualHost>

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 #

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.