How to configure server virtual hosts in Apache

Source: Internet
Author: User
1. WWW Server virtual host principle WWW Server virtual host refers to a WWW server that uses one physical machine and acts as multiple host names. For example, by a machine at the same time supply http://www.company1.com, http://www.company2.com and other WWW services, and browse

I. Principles of WWW Server virtual host

A www Server VM is a WWW server that uses a physical machine and acts as multiple host names. For example, by a machine at the same time supply http://www.company1.com, http://www.company2.com and other WWW services, and browse these WWW site users do not feel this method with different machines to provide different services.

The benefit of using WWW virtual hosts is that some small-scale websites share the same physical machine with other websites, which can reduce the operating cost of the system and reduce the difficulty of management. In addition, individual users can also use this virtual host method to create WWW Servers with their own independent domain names. Currently, many domestic companies provide this free service.

Www vm can be used in two ways:

1.1 IP address-based VM method

In this way, different host names are resolved to different IP addresses, and these IP addresses are set on the machines that provide the VM service. The server determines the virtual host service that the user requests based on the target IP address of the user's request, so as to further process the service.

Problem: The IP address-based VM method requires that multiple IP addresses be set up on the machine that provides the VM service. This not only wastes IP addresses, but also limits the number of virtual hosts that a machine can accommodate. Therefore, this method is rarely used. However, this method is the only virtual host method supported by the HTTP 1.0 protocol used in earlier versions.

1.2 Host name-based virtual host method

Because the IP address-based VM method is faulty, the support for host name-based VM is added in HTTP 1.1. Specifically, when a client sends a request to the WWW server, the Host name that the client wants to visit is also passed to the WWW server through the "Host:" statement in the request header. For example, www.company1.com and www.company2.com all correspond to the same IP address (that is, the same machine provides services for the two virtual domain names). when the customer program needs to access http://www.company1.com/index.html, the following content is included:

GET/index.html HTTP/1.1

Host: www.company1.com

.....

After receiving the request, the WWW server program can check the "Host:" statement to determine the service of the virtual Host that the client program begged for, and then proceed with the request.

Strengths: as long as one IP address is set on the machine that provides the VM service, theoretically it can provide the service to countless virtual domain names, occupying less resources and facilitating management. Currently, this method is used to provide VM services.

Problem: It cannot be used in earlier versions of HTTP 1.0. In fact, the host name-based VM method is supported on the basis of the browser of the application.

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.