PHP implements a binding of IP (e.g. 127001) and multiple domain names (virtual hosts)

Source: Internet
Author: User
Solution One: Differentiate different virtual hosts by port

① follow the method of binding a site to prepare

1. First Develop your own website (d:/myblog (stored in the MyBlog directory of D-disk))

2. Configure the httpd.conf file (stored in the Conf folder of the Apache installation directory) and enable httpd-vhosts.conf (remove the # number in front of the second line).

3. Configure the httpd-vhosts.conf file (stored in the extra folder of the Apache installation directory)

4. Add IP and domain name correspondence in the Hosts file

C:/windows/system32/drivers/etc/hosts

5. It is recommended to unregister the DocumentRoot (document root) in the httpd.conf file

6. Test, enter "Http://www.shunping1.com" in the browser to see the site homepage

② Add a new domain name to the IP binding:

1. Developing a new website: d:/myblog2

2. Configure the httpd.conf file (stored in the Conf folder of the Apache installation directory) to add a new virtual host

3. Always allow Apache to listen on 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 (must add port name)

Solution two: Distinguish different domain names through the servername end

1. Develop a new site D:/MYBLOG2

2. In the httpd.conf file, let Apache unblock 81 ports (add # or delete directly)

3. Add the configuration in the httpd-vhosts.conf file (note that the configuration and scenario one here are not the same)

4. Other configurations are the same

The above describes the PHP implementation of an IP (such as: 127001) and multiple domain names (virtual host) of the binding, including the 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.