How to configure APACHE virtual server in Oracle environment

Source: Internet
Author: User
A name-based VM has different names, but the IP address is the same. The benefit is that the number of virtual hosts is not limited, and the configuration and application are simple, without additional hardware and software. The problem is that the client must support this part of the protocol. the browsers of recent versions support this part. some old versions do not support this part. However, Apache provides a solution for this problem.

I. IP-type VM

An IP host is the unique IP address of each VM. Multiple IP addresses can be implemented through multiple physical NICs or virtual network ports. both Solaris2.5 and Windows NT support this method.

You can configure multiple VM instances in either of the following ways:

1. start an httpd process for each VM.

Apply this method in the following cases:

★Security isolation headers should be considered. for example, two httpd nodes run on different users, groups, Listen, and ServerRoot. users of both nodes cannot access other data except browsing data through the Web.

★Provides sufficient memory and file descriptors.

Setting method:

Create an independent httpd installation for each virtual host. 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. start an httpd process for all virtual hosts.

Apply this method in the following cases:

★Share httpd configurations between virtual hosts.

★The computer serves a large number of requests and runs multiple processes to reduce the server performance.

Setting method:

In the configuration file httpd. conf, use the VirtualHost command to set ServerAdmin, ServerName, DocumentRoot, ErrorLog, TransferLog, or CustomLog for each virtual host, for example:

# IP addresses are recommended here

ServerAdmin webmaster@webjx.com

DocumentRoot/usr/local/etc/httpd/htdocs/webjx

ServerName www.webjx.com # We recommend that you use a domain name here

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

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

# IP addresses are 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

At the same time, you need to configure the virtual network port or network card, and configure the corresponding settings in DNS.

II. name-based VM (supported by Apache1.3 and later versions)

Although the IP-type VM is good, it is not the best plan. It requests a dedicated IP address for each VM, which is difficult to implement on some machines.

A name-based VM has different names, but the IP address is the same. The benefit is that the number of virtual hosts is not limited, and the configuration and application are simple, without additional hardware and software. The problem is that the client must support this part of the protocol. the browsers of recent versions support this part. some old versions do not support this part. However, Apache provides a solution for this purpose.

Setting method:

In the configuration file httpd. conf, use the NameVirtualHost command to set the virtual host, for example:

NameVirtualHost
111.22.33.44
# IP addresses are recommended here
ServerName www. DOMAIN. tld # DOMAIN name is recommended here
DocumentRoot/web/DOMAIN

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

Note: When the IP address is applied after the NameVirtualHost command, the URL request of any application IP address is for the VM, and the master server will never respond to the URL request of an application IP address.

In addition, some servers expect to be visited by multiple names. For example, if a server with an IP address can be visited by DOMAIN. tld or www2.DOMAIN. tld, the ServerAlias command is applied to the VirtualHost command. For example:

ServerAlias DOMAIN. tld *. DOMAIN. tld

Additional VM configuration instances are provided.

Appendix: VM instance settings

IP-type VM 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 name of server. DOMAIN. tld (CNAME), representing the master server.

Server configuration:

...

Port 80

DocumentRoot/www/DOMAIN

ServerName www. DOMAIN. tld

DocumentRoot/www/otherDOMAIN

ServerName www. otherDOMAIN. tld

...

Setup 2: The basic is the same as Setup1, but no dedicated master server is set.

Server configuration:

...

Port 80

ServerName server. DOMAIN. tld

DocumentRoot/www/DOMAIN

ServerName www. DOMAIN. tld

...

DocumentRoot/www/otherDOMAIN

ServerName www. otherDOMAIN. tld

...

This setting hits 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 name of server. DOMAIN. tld (CNAME), representing the master server.

The www-cache.DOMAIN.tld is proxy-cache, the port is 8080, and the default 80 for Web server applications.

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 111.22.33

Name-based VM 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 Alias (CNAMEs ).

Server configuration:

...

Port 80

ServerName server. DOMAIN. tld

NameVirtualHost 111.22.33.44

DocumentRoot/www/DOMAIN

ServerName www. DOMAIN. tld

...

DocumentRoot/www/subDOMAIN

ServerName www. sub. DOMAIN. tld

...

If the application IP address accesses the server, because www. DOMAIN. tld has the highest priority, it is considered as the default server or the first server.

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 for VM instance id www. DOMAIN. tld for master server

Www. otherDOMAIN. tld is used for a virtual host, www. sub. DOMAIN. tld is used for another virtual host, and *. sub. DOMAIN. tld is used for the 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) VM configuration

Setup: The server has three IP addresses,

111.22.33.44 server. DOMAIN. tld is used for name-type virtual hosts

111.22.33.55 www. otherDOMAIN1.tld for IP-type virtual hosts

111.22.33.66 www. otherDOMAIN2.tld for IP-type virtual hosts

Server 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 VM configuration

Setup: The server has an IP address,

111.22.33.44 www. DOMAIN. tld

You can use a port-type VM to set a virtual host with a different configuration from that of the master server.

Server configuration:

...

Listen 80

Listen 8080.

ServerName www. DOMAIN. tld

DocumentRoot/www/DOMAIN

DocumentRoot/www/DOMAIN2

......

DOMAIN should be in lower case and cannot be sent to forum, so it should be in upper case


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.