Configuring multiple Web sites in XAMPP

Source: Internet
Author: User
XAMPP Virtual Host configuration, multi-domain binding access to the local site
Xampp Sometimes you need some top-level domain access to access your local project is the virtual host configuration, this time you need to configure the virtual host, to your directory binding a domain name, to achieve multi-domain binding access.
use MAMP to build a native PHP environment under MAC because of its powerful combination configuration and easy UI operation. Because the company's computer is windows, and sometimes need to set up a PHP environment to debug some small things to facilitate their work, because it is only small application, so it is not necessary to build a local WAMP environment, online WAMP Environment Integration package is a lot of, what Phpnow Ah, Wampserver Ah, phpstudy Ah, appserv ah, easyphp ah kind of I have not used, and I have been using the uniserver, dazzling ah, see me dazzled. The reason why do not use uniserver in fact I do not know, Uniserver is very strong, it is worth recommending, but later I switched to XAMPP, because it is also very powerful, and the package up to 100MB more, of course, you can download Lite version, but the file size is more than Uniserver big out several times, probably because it's big, later I switched to the XAMPP.
Sometimes you need some top-level domain access to access your local project files instead of directory access, this time you need to configure the virtual host, to your directory binding a domain name (local words can be modified by the Hosts file arbitrarily bound what domain name such as www.a.com or Localdemo).
now suppose you have two directories, one exists in/xampp/htdocs/a and the other exists in/xampp/htdocs/b.
now you want to access the local test www.a.com the corresponding directory is/xampp/htdocs/a, access www.b.com corresponding directory is/xampp/htdocs/b.
understand the Apache configuration can actually be bypassed, because XAMPP is nothing more than integration of the Apache and other environmental integration package, the implementation of multi-domain name is through the configuration APache implementation.
Of course, there are many methods of online search, but the information on the Internet is reproduced to reprint, and some methods I doubt whether the verification is correct or not know. The following method is my own test, if you follow my configuration or can not implement local multi-domain debugging, it may be because of your XAMPP version and my inconsistency caused. You can tell me in the comments below and I'll give you answers. The following configuration is for the XAMPP Windows 1.7.1 version.
1, first modify the C disk windows\system32\drivers\etc directory of the Hosts file, open with Notepad, add:

(in the end of the document)
127.0.0.1 www.a.com
127.0.0.1 www.b.com
2. Open the xampp\apache\conf\httpd.conf file and search for "Include conf/extra/httpd-vhosts.conf" to make sure that there is no # comment before, which is to ensure that vhosts is introduced The virtual host configuration file.
httpd-vhosts.conf is turned on, the default httpd.conf default configuration is disabled (ensure that the httpd-vhosts.conf file also opens the virtual host configuration, see 3rd), the domain name to access this IP will all point to vhosts.conf The first virtual host in the. (Note is the first one, see 4th)
3, in the virtual host settings file xampp\apache\conf\extra\httpd-vhosts.conf set:
cancel the # # in front of Namevirtualhost *:80 so that vhosts.conf is enabled and the default httpd.conf default configuration is invalidated. The virtual host configuration will only be set in httpd-vhosts.conf.

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


documentroot/xampp/htdocs/b
ServerName www.b.com

4, after setting the 3rd, you will find that the access to the localhost directly to the set of the path to a, the question in the 2nd has to say. That is, when the vhosts is turned on, the default httpd configuration will fail, and the default access points to the first setting in the vhosts. At this time you have to configure localhost directory to set back.

documentroot/xampp/htdocs/
ServerName localhost

at this point, XAMPP's virtual host setup is complete, now access to localhost or the original XAMPP help guide, Access www.a.com will be pointed to the binding of a directory, Access Www.b.com will point to the binding B directory.
--------------------------------------------------------------------------------
Example Reference:
Xampp Adding VirtualHost to support multiple sites
in the c:\xampp\apache\conf\extra\httpd-vhosts.conf file, add the following:
namevirtualhost *:80

documentroot "E:/php/wordpress"
ServerName WordPress

(This section must be joined or not accessible)

Options Indexes FollowSymLinks includes execcgi
AllowOverride All
Order Allow,deny
Allow from all

(This section will set the default access to localhost back, will have to be placed in the back)

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

In the Hosts file under the C:\WINDOWS\system32\drivers\etc directory, add the following:
127.0.0.1 WordPress
Put the file in the httpd-vhosts.conf:
#NameVirtualHost *:80
Get rid of the # just fine

The above describes the XAMPP in the configuration of multiple sites, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.