Apache Server virtual web settings under UNIX platform

xiaoxiao2021-03-18  176

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:

# This site is recommended to use IP ServerAdmin Webmaster@mail.smallco.com document / usr / local / etc / httpd / htdocs / smallco servername www.smallco.com # recommended to use domain name ErrorLog / USR / local / etc / httpd / logs / smallco / error_log TransferLog / usr / local / etc / httpd / logs / smallco / access_log # proposed here with IP ServerAdmin webmaster @ mail. baygroup.org DocumentRoot / groups / baygroup / www ServerName www.baygroup.org # suggestion here the domain name ErrorLog / groups / baygroup / logs / error_log TransferLog / groups / baygroup / logs / access_log

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 #Newrly Use IP ServerName www.domain.tld # recommended to use DOCUMENTROOT / Web / Domain

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 DocumentRoot / WWW / OtherDomain ServerName www.othersDomain.tld ...

Setup 2: Basically with Setup1, but does not set a special primary server. Server configuration: ... Port 80 ServerName server.domain.tld DocumentRoot / www / domain ServerName www.domain.tld ... DocumentRoot / www / otherdomain ServerName Www.otherdomain.tld ... This setting only hits the primary server when the URL is http: //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 DocumentRoot / www / domain servername www.domain.tld ... ServerName www-cache.domain.tld ... Order Deny, Allow Deny from all allow from 31.22.33 Name type virtual host Configure

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 DocumentRoot / www / domain ServerName www.domain.tld ... DocumentRoot / Www.sub.domain servername www.sub.domain.tld ... If the IP access server is used, since www.domain.tld has the highest priority, it is considered a default server or a first server. Setup 2: The server has two IPs, 111.22.33.44 server1.domain.tld is used for primary server 111.22.33.55 server2.domain.tld is used for virtual host alias www.domain.tld is used for primary servers, alias www.othersDomain.tld For a virtual host, alias www.sub.domain.tld, *. Sub.Domain.tld is used for another virtual host, server configuration: ... Port 80 Servername www.domain.tld DocumentRoot / WWW / Domain NameVirtualHost 111.22 .33.55 DocumentRoot / www / otherdomain ServerName www.otherdomain.tld ... DocumentRoot / www / subdomain ServerName www.sub.domain.tld ServerAlias ​​* .sub. Domain.TLD ...

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 DocumentRoot / www / domain ServerName www.domain.tld ... DocumentRoot / www / subdomain1 ServerName www.sub1.domain.tld ... DocumentRoot / www / subdomain2 ServerName www.sub2.domain.tld ... DocumentRoot / www / otherdomain1 servername www.otherdomain1.tld ... DocumentRoot / www / otherdomain2 servername www.otherdomain2.tld ... port type virtual host configuration

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 Documentroot / WWW / Domain2 ...

转载请注明原文地址:https://www.9cbs.com/read-129752.html

New Post(0)