Apache server an IP (such as: 127.0.0.1) and multiple domain names (virtual host) of the binding _linux

Source: Internet
Author: User

Today in the study of PHP, there is such a requirement: an IP (such as: 127.0.0.1) and multiple domain names (virtual host) binding, the following is my solution:

Solution One: differentiate the different virtual hosts through the ports

① the way to bind a site

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

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

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

4. Add IP and domain name correspondence in Hosts file

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

5. It is recommended to unregister DocumentRoot (document Root), 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 with this IP binding:

1. Develop a new website: d:/myblog2

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

3. In the httpd.conf file always let Apache listen to 81 ports

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: differentiate different domain names by servername end

1. Develop a new site D:/MYBLOG2

2. In the httpd.conf file let Apache cancel listening to 81 ports (plus # or delete directly in front)

3. Add the configuration in the httpd-vhosts.conf file (note that the configuration and scenario one is different here)

4. Other configurations are unchanged

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.