Author: tree2000 ----------------------------------------------- ------------------------------- UNIX platform with the NT platform to use the Apache Server settings. The following focuses on the UNIX platform as an example to illustrate the setting of the Apache Server. It is also worth noting that the successful setting of virtual Web has a workload of approximately 50% is registration and parsing in the domain name. So generally register a good domain name and then do virtual web settings.
First, IP type virtual host
The IP type virtual host refers to each virtual host corresponding to a unique IP. This approach can be implemented by multiple IPs, Solaris 2.5, and Windows NT through multiple physical NICs or virtual network ports. Two ways to configure multiple virtual hosts:
1. Start an HTTPD process for each virtual host. Under the following cases: 1) Consider safety isolation, such as two HTTPDs running in different USER, Group, Listen, ServerRoot, both users browse data through web, unable to access other data.
2) Provide sufficient memory and file descriptor. Setting method: Create a separate HTTPD installation for each virtual host, in each installation path httpd.conf, use the Listen instruction to specify the IP of the process service, such as: Listen 10.68.37.10:80
2. Start an HTTPD process for all virtual hosts. Use this method in the following cases:
1) Allow sharing HTTPD configuration between the virtual host.
2) Computer services to a large number of requests, run multiple processes to reduce server performance into important considerations.
Setting method: In the configuration file httpd.conf, set ServerAdmin, ServerName, Document, ErrorLog, Transferlog, or Customlog, such as:
At the same time, you have to do a virtual network port or network card configuration, and you must do the corresponding settings in DNS.
Second, named virtual hosts (Apache 1.3 or above support)
Although the IP-type virtual host is good, it is not the best solution. It requires every virtual host to have a dedicated IP, which is difficult to implement in some machines. Name type virtual host refers to the name of each virtual host, but IP is the same. It is the benefit of not limiting the number of virtual hosts, configures, easy to use, no additional hardware and software. Disadvantages are that the client must support this part of the protocol, and the recent version of browser supports, some old version browsers do not support. But Apache provides a solution to this. Setting method: In the configuration file httpd.conf, set the virtual host with the NameVirtualHost directive, such as:
NamevirtualHost 111.22.33.44
At the same time, the DNS defines www.domain.tld points to 111.22.33.44. Note: When using IP after the NameVirtualHost instruction, any URL request to use IP is for a virtual host, and the primary server never responds to a URL request using IP. In addition, some servers want to be accessed in multiple names. For example, assume that there is a server server, you want to be visited in name Domain.TLD, www2.domain.tld, and the practice is to use the Serveralias instruction in the VirtualHost instruction section. Such as: Serveralias Domain.tld * .domain.tld Also supplies some virtual host setting instances.
Attachment: Virtual Host Setting Example
IP type virtual host configuration
Setup 1: The server has two IPs, 111.22.33.44 server.domain.tld 111.22.33.55 www.tldomain.tld www.domain.tld is the alias (CNAME) of Server.Domain.TLD, represents the primary server. Server configuration: ... Port 80 Documentroot / WWW / Domain ServerName www.domain.tld
Setup 2: Basically with Setup1, but does not set a special primary server. Server configuration: ... Port 80 ServerName server.domain.tld
SETUP 3: The server has two IP, 111.22.33.44 server.domain.tld 111.22.33.55 www-cache.domain.tld www.domain.tld is the alias (CNAME) of Server.Domain.tld, represents the primary server. Www-cache.domain.tld is Proxy-Cache, the port is 8080, and the web server uses the default 80. Server configuration: ... Port 80 listen 111.22.33.44:80 listen 111.22.33.55:8080 servername server.domain.tld
Setup 1: The server has an IP, 111.22.33.44 server.domain.tld. Www.domain.tld and www.sub.domain.tld are unique (cnames). Server configuration: ... Port 80 ServerName server.domain.tld NameVirtualHost 111.22.33.44
Hybrid (IP / Name) virtual host configuration
Setup: The server has three IPs, 111.22.33.44 server.domain.tld For named virtual hosts 111.22.33.55 www.otherdomain1.tld is used for IP type virtual host 111.22.33.66 www.otherdomain2.tld is used for IP virtual host servers configuration: ... Port 80 ServerName server.domain.tld NameVirtualHost 111.22.33.44
Setup: The server has an IP, 111.22.33.44 www.domain.tld does not require additional alias or IP, using a port type virtual host to set a virtual host that is different from the primary server. Server configuration: ... listen 80 listen 8080 ServerName www.domain.tld Document / WWW / Domain