Site Environment Apache + PHP + mysql xampp, how to implement a server on the configuration of multiple sites?

Source: Internet
Author: User
Tags tld

XAMPP is a very convenient local Apache + php + MySQL debugging environment, in the local installation test WordPress and other various blogs, forum procedures very convenient. Today we are going to show you how to use XAMPP to install multiple websites locally.

In general, we only need to put the website program into the Xampp/htdoc directory, and then enter the IP address in the browser HTTP://127.0.0.1/or enter the domain name http://localhost/can be. But then we can only use one program to build a website. If we want to test different programs, such as a WordPress website, a discuz! forum, plus a Shopex online shop, it is more troublesome. This article, we will introduce you how to add multi-site support in Xampp, so that you can easily install multiple sites.

For example, we want to install two test domain names locally, www.abc.tld, Www.xyz.tld, respectively, to the Abc.tld and Xyz.tld folders under the Htdoc directory. TLD is the acronym for the top domain of the TLDs. If you like, you can also use abc.com, abc.net such a top-level domain to replace. TLD is used here primarily to avoid conflicts with real domain names.

1. In hostsSet the domain name resolution in the file (host related article: http://whosmall.com/?sort=5

As with the normal domain name, these two domain names do not exist, we also need to parse; otherwise the browser does not know where to find the server. Let's use the local hosts file to solve this problem. This file is used to specify the mapping relationship between the domain name and the IP address. When you want to enter a Web site for access in the browser, the browser issues a domain name resolution request to the local network's DNS server. However, before the resolution request is issued, the hosts file is first searched for a parse record, and if there is a record of the domain name, it is accessed using that record. Therefore, this file is equivalent to the cache file for domain name resolution.

The Hosts file is saved in the C:\Windows\System32\drivers\etc directory with no extension, using a text editor (NotePad, Notepad, EmEditor, UltraEdit, etc.) can open the edit, if it is Windows Vista or Windows 10, you need to first open Notepad with administrative rights.

We then add two rows of domain name resolution records at the end of the file, one for each domain name. The front is an IP address, space is separated by a space or tab, followed by a domain name:

127.0.0.1 Www.abc.tld

127.0.0.1 Www.xyz.tld

As shown in the following:

Then save the Hosts file.

2. Add two folders under the Htdocs directory

We created two folders under the Xampp/htdocs directory, named Www.abc.tld and Www.xyz.tld, respectively. The name of the file directory is set to the domain name format for ease of differentiation, not mandatory, as long as the directory name and the following settings are consistent.

We add a index.html file in the Www.abc.tld directory with the following content:

 
  

Also add an identical index.html file in the Www.xyz.tld directory, replacing ABC with XYZ.

Note that this index.html file does not conform to the HTML specification, but is used to verify the success of our multi-domain support.

3. Add multi-domain support in Apache

The most critical step in your current age is to concentrate on your attention. Let's get Apache to bind multiple domain names and support access to multiple sites.

To open a file using the file Editor:xampp/apache/conf/extra/httpd-vhosts.conf .

First find namevirtualhost *:80 , remove the previous comment symbol #. If you do not have this line, add a row yourself.

Then add the following code:

<virtualhost *:80>    ServerAdmin [email protected]    documentroot "/xampp/htdocs/www.abc.tld"    ServerName www.abc.tld    errorlog "Logs/www.abc.tld-error.log"    customlog "Logs/www.abc.tld-access.log" combined</virtualhost> <virtualhost *:80>    ServerAdmin [email protected]    DocumentRoot "/xampp/ Htdocs/www.xyz.tld "    ServerName www.xyz.tld    errorlog" Logs/www.xyz.tld-error.log "Customlog" logs/    Www.xyz.tld-access.log "combined</virtualhost>

After you add it, save the file. Httpd-vhosts.conf in code such as:

4. Restart Apache and verify multi-domain

After the filming is complete, restart the Apache service and reopen the browser. and enter Http://www.abc.tld and HTTP://WWW.XYZ.TLD separately in the browser, you can see the following results separately:

After setting, enter HTTP://WWW.ABC.TLD and Http://www.xyz.tld separately in the browser, the different content will be displayed. If you see the content and the same, that means your XAMPP support multi-domain has been set up successfully. Otherwise, check from the beginning to see where the error has been set.

At last...

It this line, not to go to Google data, finally, Amway a V--PN agent. a red apricot VPN, to Google to check the information is the absolute first choice, the connection speed, the use is also convenient. I bought is 99¥ a year, through this link (http://my.yizhihongxing.com/aff.php?aff=2509) registered after the Member center to lose the coupon code, split down, only 7 yuan per month, special benefits.

This article tags: lampp Build station lampp Download install xampp Linux edition

Turn from SUN's BLOG-focus on Internet knowledge, share the spirit of the Internet!
The original address of the site environment Apache + PHP + mysql xampp, how to implement a server on the configuration of multiple sites? 》

related reading:"What is an engineer culture?" Why are the engineers alive? Why do I need an engineer culture as an IT or internet company?

related reading: useful to programmers: 2017 latest in Google's Hosts file download and summary of the various hosts encountered the problem of the solution and configuration of the detailed

related reading: the Win10 perpetual activation tutorial and how can I see if the Windows system is permanently activated? 》

Related blog:SUN ' S blog -Focus on Internet knowledge and share the spirit of Internet! Go and see:www.whosmall.com

Site Environment Apache + PHP + mysql xampp, how to implement a server on the configuration of multiple sites?

Related Article

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.