Apache + Tomcat Single IP multi-domain name multi-application configuration

Source: Internet
Author: User
Assume that the IP address 192.168.1.2 of a host HostA is bound to HOSTA. There are two J2EE applications APPA and APPB on the host, and the domain names www.linuxidc.com and www.linuxidc.net correspond to two applications respectively. Environment: centos5.6jdk1.6. xtomcat6.xapache2.2.3 deployment Description: apache forwards requests as a web Server

Assumptions:

One host, HostA, with the IP address 192.168.1.2 bound to HOSTA, has two J2EE applications, APPA and APPB, with the domain name www. linux.IdC.com and www.linuxidc.net correspond to two applications respectively.

Environment:

Centos 1, 5.6

Jdk1.6.x

ToMcAt6.x

Apache2.2.3

Deployment description:

Apache forwards requests to tom as a web ServerCatProcessing: tomcat is used as the application server to process requests. Only one application is deployed for each tomcat.

By default, you are familiar with jdk installation, tomcat deployment configuration, and apache deployment configuration.

1. Modify the hosts configuration file

  1. 127.0.0.1 hostname localhost www.domainain.com www.domainbin.com
Www.domainain.com and www.domainbin.com are appended for future use.

2. Deploy the application APPA

2.1 clear built-in tomcat applications and manage applications

Delete all directories under webapps

  1. Drwxr-xr-x 3 d t 4096 Aug 17 ROOT
  2. Drwxr-xr-x 10 d t 4096 Aug 17 docs
  3. Drwxr-xr-x 5 d t 4096 Aug 17 14:29ExAmples
  4. Drwxr-xr-x 5 d t 4096 Aug 17 host-manager
  5. Drwxr-xr-x 5 d t 4096 Aug 17 manager
Delete all files under conf/Catalina/localhost
  1. -Rw-r -- 1 d t 904 Aug 17 host-manager.xml
  2. -Rw-r -- 1 d t 904 Aug 17 manager. xm
2.2 modify server. xml

A. Modify the Host Node

Find the following configuration

  1. <Host Name="Localhost"AppBase="Webapps"
  2. UnpackWARs="TrUe" AutoDeploy="True"
  3. XmlValidation="FaLsE" XmlNamespaceAware="False">
Change
  1. <Host Name="Appa"
  2. UnpackWARs="True" AutoDeploy="True"
  3. XmlValidation="False" XmlNamespaceAware="False">

B. Modify the Engine Node

Find the following configuration

  1. <Engine Name="Catalina" DefaultHost="Localhost">
Change
  1. <Engine Name="Catalina" DefaultHost="Appa">
DefaultHost = "appa" to be associated Appa"Consistent.

2.3 add ROOT. xml configuration

Create a directory named appa in the conf/Catalina directory Appa"Consistent, the file content is as follows

  1. <Context DocBase="/Opt/app/apparoot"
  2. PrivilegEd="True" AntiResourceLocking="False" AntiJARLocking="False">
  3. Context>
2.4 place applications

Create the path in docBase = "/opt/app/apparoot" in step 1 (you do not need to create another ^-^ if you have already created the path ). Place the application in this directory.

Note: You can directly place the files in the application. In this way, you can directly access your application using http: // localhost: 8080.

2.5 start tomcat

After tomcat is started, you can access http: // localhost: 8080 on the local machine. If you can access the appa application, the configuration is successful. If an error occurs, view the logs in logs.

If there is no graphical interface, use wget http: // localhost: 8080 for testing.

3. Deploy APPB

The overall process is the same as that for deploying APPA. Note that you must modify the port numbers in tomcat deployed in APPB. We recommend that you adjust the port numbers in server. xml in a unified manner. The http port of APPB is 9080.

Related Article

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.