ApacheServer sets virtual WEB

Source: Internet
Author: User
Tags dedicated ip domain name registration in domain subdomain
The settings of apacheserver for unix and NT platforms are the same. The following describes apacheserver settings on the unix platform. In addition, it is worth noting that about 50% of the workload for successful virtual web settings is in domain name registration and resolution. Therefore, you should register the domain name before setting the virtual WEB. I. virtual IP Address

The settings for using apache server on unix and NT platforms are the same. The following describes how to configure apache server on the unix platform. In addition, it is worth noting that about 50% of the workload for successful virtual web settings is in domain name registration and resolution. Therefore, you should register the domain name before setting the virtual WEB. I. virtual IP Address

The unix and NT platforms use SetSame. The following uses the unix platform as an example to describe Set. In addition, it is worth noting that, VirtualWeb success SetAbout 50% of the workload is in domain name registration and resolution. So register the domain name first and then VirtualWEB Set.

I. IP type VirtualHost

IP VirtualHost VirtualThe unique IP address of the host. Multiple Physical NICs or VirtualMultiple IP addresses are implemented at the network port. Both Solaris2.5 and Windows NT support this method.

Multiple configurations VirtualHost method:

1. For each VirtualThe host starts an httpd process.

Use this method in the following cases:

1) Security Isolation needs to be considered. For example, two httpd instances run on different users, groups, Listen, and ServerRoot instances. In addition to browsing data through the Web, the two users cannot access other data.

2) provides sufficient memory and file descriptors.

SetMethod:

For each VirtualThe host establishes an independent httpd installation. In the configuration file httpd. conf of each installation path, use the Listen command to specify the IP address of the process service, for example, Listen 10.68.37.10: 80.

2. for all VirtualThe host starts an httpd process.

Use this method in the following cases:

1) allow VirtualShare httpd configurations between hosts.

2) computers serve a large number of requests and run multiple processes to reduce server performance.

SetMethod:

In the configuration file httpd. conf, use the VirtualHost command VirtualHost SetServerAdmin, ServerName, DocumentRoot, ErrorLog, TransferLog, or CustomLog, for example:

<VirtualHost www.smallco.com> # IP address is recommended here

ServerAdmin webmaster@mail.smallco.com

DocumentRoot/usr/local/etc/httpd/htdocs/smallco

ServerName www.smallco.com # we recommend that you use a domain name here

ErrorLog/usr/local/etc/httpd/logs/smallco/error_log

TransferLog/usr/local/etc/httpd/logs/smallco/access_log

</VirtualHost> 〉

<VirtualHost www.baygroup.org> # IP address is recommended here

ServerAdmin webmaster@mail.baygroup.org

DocumentRoot/groups/baygroup/www

ServerName www.baygroup.org # domain names are recommended here

ErrorLog/groups/baygroup/logs/error_log

TransferLog/groups/baygroup/logs/access_log

</VirtualHost> 〉

At the same time VirtualConfigure the network port or Nic in DNS Set.

Ii. Name type VirtualHost (supported by Apache1.3 and later versions)

IP VirtualAlthough the host is good, it is not the best solution. It requires each VirtualThe host has a dedicated IP address, which is difficult to implement on some machines. Name type VirtualHost refers to each VirtualThe host name is different, but the IP address is the same. Its advantage is that it is unlimited. VirtualThe number of hosts, which is easy to configure and use without additional hardware and software. The disadvantage is that the client must support this part of the protocol, which is supported by browsers of recent versions. Some earlier versions of browsers do not. However, Apache provides a solution for this.

SetMethod:

Use the NameVirtualHost command in the configuration file httpd. conf. Set VirtualHost, such:

NameVirtualHost 111.22.33.44

<VirtualHost 111.22.33.44> # IP address is recommended.

ServerName www. domain. tld # domain name is recommended here

DocumentRoot/web/domain

</VirtualHost> 〉

At the same time, the DNS defines www. domain. tld pointing to 111.22.33.44.

Note: When the IP address is used after the NameVirtualHost command, any URL request using the IP address is VirtualThe master server will never respond to a URL request using an IP address. In addition, some servers want to be accessed by multiple names. For example, if a server with an IP address wants to be accessed by domain. tld and www2.domain. tld, The ServerAlias command is used in the VirtualHost command. For example, ServerAlias domain. tld *. domain. tld

Additional VirtualHost SetInstance.

Appendix: VirtualHost SetInstance

IP type VirtualHost Configuration

Setup 1: the server has two IP addresses,

111.22.33.44 server. domain. tld

111.22.33.55 www. otherdomain. tld

Www. domain. tld is the alias of server. domain. tld (CNAME), representing the master server.

Server Configuration:

...

Port 80

DocumentRoot/www/domain

ServerName www. domain. tld

<VirtualHost 111.22.33.55> 〉

DocumentRoot/www/otherdomain

ServerName www. otherdomain. tld

...

</VirtualHost> 〉

Setup 2: basically the same as Setup1, but not SetDedicated master server.

Server Configuration:

...

Port 80

ServerName server. domain. tld

<VirtualHost 111.22.33.44> 〉

DocumentRoot/www/domain

ServerName www. domain. tld

...

</VirtualHost> 〉

<VirtualHost 111.22.33.55> 〉

DocumentRoot/www/otherdomain

ServerName www. otherdomain. tld

...

</VirtualHost> 〉

This SetHit the master server only when the URL is http://server.domain.tld

Setup 3: the server has two IP addresses,

111.22.33.44 server. domain. tld

111.22.33.55 www-cache.domain.tld

Www. domain. tld is the alias of server. domain. tld (CNAME), representing the master server.

The www-cache.domain.tld is the 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

<VirtualHost 111.22.33.44: 80> 〉

DocumentRoot/www/domain

ServerName www. domain. tld

...

</VirtualHost> 〉

<VirtualHost 111.22.33.55: 8080> 〉

ServerName www-cache.domain.tld

...

<Directory proxy:> :〉

Order deny, allow

Deny from all

Allow from 111.22.33

</Directory> 〉

</VirtualHost> 〉

Name type VirtualHost Configuration

Setup 1: the server has an IP address,

111.22.33.44 server. domain. tld.

Www. domain. tld and www. sub. domain. tld are aliases (CNAMEs ).

Server Configuration:

...

Port 80

ServerName server. domain. tld

NameVirtualHost 111.22.33.44

<VirtualHost 111.22.33.44> 〉

DocumentRoot/www/domain

ServerName www. domain. tld

...

</VirtualHost> 〉

<VirtualHost 111.22.33.44> 〉

DocumentRoot/www/subdomain

ServerName www. sub. domain. tld

...

</VirtualHost> 〉

If you use an IP address to access the server, because www. domain. tld has the highest priority, it is considered as the default server or

Server 1.

Setup 2: the server has two IP addresses,

111.22.33.44 server1.domain. tld for master server

111.22.33.55 server2.domain. tld is used VirtualHost

The alias www. domain. tld is used for the master server,

The alias www. otherdomain. tld is used for VirtualHost,

The alias www. sub. domain. tld, *. sub. domain. tld is used for another VirtualHost,

Server Configuration:

...

Port 80

ServerName www. domain. tld

DocumentRoot/www/domain

NameVirtualHost 111.22.33.55

<VirtualHost 111.22.33.55> 〉

DocumentRoot/www/otherdomain

ServerName www. otherdomain. tld

...

</VirtualHost> 〉

<VirtualHost 111.22.33.55> 〉

DocumentRoot/www/subdomain

ServerName www. sub. domain. tld

ServerAlias *. sub. domain. tld

...

</VirtualHost> 〉

Hybrid (IP/name) VirtualHost Configuration

Setup: the server has three IP addresses,

111.22.33.44 server. domain. tld for name Type VirtualHost

111.22.33.55 www. otherdomain1.tld for IP VirtualHost

111.22.33.66 www. otherdomain2.tld for IP VirtualHost

Server Configuration:

...

Port 80

ServerName server. domain. tld

NameVirtualHost 111.22.33.44

<VirtualHost 111.22.33.44> 〉

DocumentRoot/www/domain

ServerName www. domain. tld

...

</VirtualHost> 〉

<VirtualHost 111.22.33.44> 〉

DocumentRoot/www/subdomain1

ServerName www. sub1.domain. tld

...

</VirtualHost> 〉

<VirtualHost 111.22.33.44> 〉

DocumentRoot/www/subdomain2

ServerName www. sub2.domain. tld

...

</VirtualHost> 〉

<VirtualHost 111.22.33.55> 〉

DocumentRoot/www/otherdomain1

ServerName www. otherdomain1.tld

...

</VirtualHost> 〉

<VirtualHost 111.22.33.66> 〉

DocumentRoot/www/otherdomain2

ServerName www. otherdomain2.tld

...

</VirtualHost> 〉

Port type VirtualHost Configuration

Setup: the server has an IP address,

111.22.33.44 www. domain. tld

No other alias or IP address is required. Port type is used. VirtualHost SetA configuration is different from a virtual server

VM instance.

Server Configuration:

...

Listen 80

Listen 8080.

ServerName www. domain. tld

DocumentRoot/www/domain

<VirtualHost 111.22.33.44: 8080> 〉

DocumentRoot/www/domain2

...

</VirtualHost> 〉

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.