[Transfer] Configure multiple websites in XAMPP, configure multiple xampp_PHP tutorial

WBOY
Release: 2016-07-13 09:46:15
Original
1119 people have browsed it

[Transfer] Configure multiple websites in XAMPP, configure multiple xampp

XAMPP virtual host configuration, bind multiple domain names to access local sites

XAMPP Sometimes you need some top-level domain name access methods to access your local project, which is the virtual host configuration. At this time, you need to configure the virtual host and bind a domain name to your directory to achieve multi-domain binding. access.


I have always used MAMP to build a local php environment on Mac because of its powerful combination configuration and convenient UI operation. Because the company's computers are Windows, sometimes you need to set up a PHP environment to debug some small things to facilitate your work. Since it is just a small application, there is no need to build a local WAMP environment by yourself. There are still many WAMP environment integration packages online. I have never used PHPNow, WampServer, PHPStudy, AppServ, EasyPHP, etc., and UniServer, which I have been using before, is so dazzling that I am dazzled. I actually don’t know the reason why I didn’t use UniServer later. UniServer is very powerful and worth recommending, but then I switched to XAMPP because it is also very powerful and the file package is more than 100MB. Of course, you can download the Lite version. , but the file size is several times larger than UniServer. Maybe it was because of its size that I later switched to XAMPP.

Sometimes you need some top-level domain name access methods to access your local project files instead of directory access. In this case, you need to configure a virtual host and bind a domain name to your directory. (If you are local, you can bind any domain name such as www.a.com or localdemo by modifying the hosts file).
Now assume you have two directories, one exists in /xampp/htdocs/a and the other exists in /xampp/htdocs/b.
Now when you want to access www.a.com for local testing, the corresponding directory is /xampp/htdocs/a, and the corresponding directory for accessing www.b.com is /xampp/htdocs/ b.
If you know how to configure Apache, you can actually avoid it, because XAMPP is nothing more than integrating environment integration packages such as APache, and implementing multiple domain names is achieved by configuring Apache.

Of course, there are many methods that can be found online, but the information on the Internet is reprinted and reprinted. I doubt whether some methods have been verified or not and I don’t know whether they are correct. The following method was personally tested by me. If you still cannot achieve local multi-domain debugging according to my configuration, it may be because your XAMPP version is inconsistent with mine. You can tell me in the comments below and I will answer it for you. The following configuration is for XAMPP Windows 1.7.1 version.

1. First modify the hosts file in the WINDOWSsystem32driversetc directory on the C drive, open it with Notepad, and add:

(added at the end of the file)
127.0.0.1 www.a.com
127.0.0.1 www.b.com

2. Open the xamppapacheconfhttpd.conf file, search for "Include conf/extra/httpd-vhosts.conf", and make sure there is no # comment in front, that is, make sure the vhosts virtual host configuration file is introduced .

When httpd-vhosts.conf is enabled, the default httpd.conf default configuration becomes invalid (make sure the virtual host configuration is also enabled in the httpd-vhosts.conf file, see Article 3), Domain names accessing this IP will all point to the first virtual host in vhosts.conf. (Note that it is the first one, see Chapter 4 for details)

3. Set in the virtual host setting file xamppapacheconfextrahttpd-vhosts.conf:
Cancel NameVirtualHost *:80 The ## in front of this will enable vhosts.conf, and the default httpd.conf default configuration will be invalid. 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 up item 3, you will find that access localhost points directly to the path set as a. This issue is discussed in Article 2. That is to say, after vhosts is enabled, the default httpd configuration will become invalid, and the default access will point to the first setting in vhosts. At this time, you need to set back the localhost directory configuration.

DocumentRoot /xampp/htdocs/
ServerName localhost


At this point, the XAMPP virtual host is set up. Now access localhost or the original XAMPP help guide. Access www.a.com will point to the bound a directory, accessing www.b.com will point to the bound b directory.

----------------------------------------- ------------------------------------------

Instance reference:
XAMPP adds VirtualHost to support multiple sites
Add the following content in the c:xamppapacheconfextrahttpd-vhosts.conf file:

NameVirtualHost *:80


DocumentRoot "E:/php/wordpress"
ServerName wordpress

(This paragraph must be added, otherwise it will be inaccessible)

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

(This paragraph returns the localhost default access setting and must be placed at the end)

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


In the C:WINDOWSsystem32driversetc directory Add the following content to the hosts file:

127.0.0.1 wordpress

Place the file httpd-vhosts.conf:
#NameVirtualHost *:80

Just remove the #

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1034506.htmlTechArticle[Transfer] Configure multiple websites in XAMPP, configure multiple XAMPP virtual host configurations in xampp, and bind access to multiple domain names Local site XAMPP Sometimes you need some top-level domain name access methods to access your local site...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!