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 binding 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:
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 are no # annotations in front of you, which is to ensure that the Vhosts virtual host configuration file is introduced.
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.
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.
<virtualhost *:80>
documentroot/xampp/htdocs/a
ServerName www.a.com
</VirtualHost>
<virtualhost *:80>
Documentroot/xampp/htdocs/b
ServerName www.b.com
</VirtualHost>
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.
<virtualhost *:80>
documentroot/xampp/htdocs/
ServerName localhost
</VirtualHost>
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.
--------------------------------------------------------------------------------------------------------------- ----------------------------------------------------
Another article to do a reference:
Xampp adding VirtualHost to support multiple sites
Saturday, June 06, 2009 03:46 p.m.
In the c:\xampp\apache\conf\extra\httpd-vhosts.conf file, add the following:
Namevirtualhost *:80
<virtualhost *:80>
DocumentRoot "d:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
<virtualhost *:80>
DocumentRoot "E:/php/wordpress"
ServerName WordPress
</VirtualHost>
<directory "E:/php/wordpress" >
Options Indexes FollowSymLinks includes execcgi
AllowOverride All
Order Allow,deny
Allow from all
</Directory>
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
Configuring multiple Web sites in XAMPP