PHP binds an ip address (for example, 127001) to multiple domain names (virtual hosts ).

Source: Internet
Author: User
: This article describes how to bind an ip address (for example, 127001) to multiple domain names (virtual hosts) in PHP. For more information about PHP tutorials, see. Solution 1: differentiate virtual hosts through ports

① Prepare for binding a site

1. first open your website (d:/myblog (stored in the myblog directory of drive d ))

2. configure the httpd. conf file (stored in the conf folder of the apache installation directory) and enable the httpd-vhosts.conf (remove the # sign before the second line ).

3. configure the httpd-vhosts.conf File (stored in the extra folder in the apache installation directory)

4. add the ing between ip address and domain name in the hosts file

C:/Windows/System32/drivers/etc/hosts

5. we recommend that you log out of DocumentRoot (the root directory of the document). in the httpd. conf file

6. test, enter "http://www.shunping1.com" in the browser to see the site home page

② Add a new domain name and bind it to the ip address:

1. develop a new website: d:/myblog2

2. configure the httpd. conf file (stored in the conf folder of the apache installation directory) and add a new VM.

3. make apache listen to port 81 in the httpd. conf file.

4. add a new domain name to the hosts file

5. test, enter http://www.shunping3.com: 80 in the browser (the port name must be added)

Solution 2: differentiate different domain names through ServerName

1. develop a new site d:/myblog2

2. in the httpd. conf file, enable apache to cancel listening to port 81 (add # in front or delete it directly)

3. add the configuration in the httpd-vhosts.conf File (note that the configuration here is different from solution 1)

4. other configurations remain unchanged

The preceding section describes how to bind an ip address (such as 127001) to multiple domain names (virtual hosts) in PHP, including related content. I hope to help my friends who are interested in PHP tutorials.

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.