Apache integrates multiple Tomcat and one Tomcat corresponds to one application. Different domain names access different applications.

Source: Internet
Author: User
Apache integrates multiple Tomcat and one Tomcat corresponds to one application. Different domain names access different applications.

From: http://apps.hi.baidu.com/share/detail/20890923

 

To configure multiple Tomcat servers, you only need to change the 80, 8009, and ports to run n Tomcat servers on one server at the same time.

The following describes how to use one Apache to activate multiple Tomcat servers:

1. Apache HTTP. conf settings

<Virtualhost 192.168.1.20>
Serveradmin *** @ ***. com
Servername www. ****. com
Serveralias www. ****. com
Errorlog D:/logs1/** -host.example.com-error_log
Customlog D:/logs1/** -host.example.com-access_log common
Jkmount/*. jsp work1
Jkmount/* work1
</Virtualhost>

<Virtualhost 192.168.1.20>
Serveradmin ** @ **. com
Servername www. **. com
Serveralias www. **. com
Errorlog D:/logs/** -host.example.com-error_log
Customlog D:/logs/** -host.example.com-access_log common
Jkmount/*. jsp work2
Jkmount/* work2
</Virtualhost>

2. Works. properties content

Workers. tomcat_home = D: \ tomcat5
Workers. java_home = c: \ jdk1.5
PS = \
Worker. List = work1, work2
Worker. work1.port = 8009
Worker. work1.host = 127.0.0.1
Worker. work1.type = ajp13
Worker. work1.lbfactor = 1

Worker. work2.port = 8014
Worker. work2.host = 127.0.0.1
Worker. work2.type = ajp13
Worker. work2.lbfactor = 1

3. Modify the host name attribute in Tomcat server. xml configuration:

<Host name = "www. ****. com" DEBUG = "0" appbase = "webapps" reloadable = "true">

[Wind_rain ]:
Mark

[Onlyfor_love ]:
Stick to it

[Steven _cheng ]:

Thank you.
I used the JK2 plug-in, Linux system. Is the configuration successful in this environment?
How to define multiple workers in workers2.properties and forward according to different conditions...
Thank you.

[Pigo ]:

Since Apache is used, why does JK2 need to be used?

I only have mod_ajp combined with the virtual host configuration.

[Xiangze98 ]:
Re: Steven _ Cheng (286)
Dude, the configuration methods for various operating systems are similar. Your question has been answered in the previous reply. Repeat:

Define multiple works:
Worker. List = work1, work2,... workn
Worker. work1.port = 8009
Worker. work1.host = IP1
Worker. work1.type = ajp13
Worker. work1.lbfactor = 1

Worker. work2.port = 8009
Worker. work2.host = ip2
Worker. work2.type = ajp13
Worker. work2.lbfactor = 1
....
....
Worker. workn. Port = 8009
Worker. workn. Host = IPN
Worker. workn. type = ajp13
Worker. workn. lbfactor = 1

Forwarding Based on different conditions is configured in Apache. Each domain name uses a different workn and forwards the request to the corresponding application server.
1. Apache HTTP. conf settings

<Virtualhost 192.168.1.20>
Serveradmin *** @ ***. com
Servername www. ****. com
Serveralias www. ****. com
Errorlog D:/logs1/** -host.example.com-error_log
Customlog D:/logs1/** -host.example.com-access_log common
Jkmount/*. jsp work1
Jkmount/* work1
</Virtualhost>

<Virtualhost 192.168.1.20>
Serveradmin ** @ **. com
Servername www. **. com
Serveralias www. **. com
Errorlog D:/logs/** -host.example.com-error_log
Customlog D:/logs/** -host.example.com-access_log common
Jkmount/*. jsp work2
Jkmount/* work2
</Virtualhost>

[Safesoft ]:
Too advanced. Let me hear from you.

[Tomcat4 ]:
I would like to ask the landlord how to configure two Tomcat instances on one and above. Do Two Tomcat instances share the ctalina_base environment variable? If the variables are shared, the two Tomcat instances are in a directory, is it a tomcat service?

[Wind0717 ]:
I would like to ask how to configure a second-level domain name under tomcat. Could you give me a detailed introduction? Thank you

Environment:
Windows 2003
Jdk1.5
Tomcat5.5
Site Directory D: \ Tomcat \ webapps \ ABC
Second-level domain name: BBS. ****. com

I found a lot on the Internet, but it was unsuccessful, including in the csdn community.
Which experts can help solve this problem?

[Championmajian ]:
No Tomcat started at the same time
Learning

[Fangtaohbjjxy ]:
For more information, see my blog.

[Sczk001 ]:
<Virtualhost 192.168.1.20>
Serveradmin *** @ ***. com
Servername www. ****. com
Serveralias www. ****. com
Errorlog D:/logs1/** -host.example.com-error_log
Customlog D:/logs1/** -host.example.com-access_log common
Jkmount/*. jsp work1
Jkmount/* work1
</Virtualhost>

<Virtualhost 192.168.1.20>
Serveradmin ** @ **. com
Servername www. **. com
Serveralias www. **. com
Errorlog D:/logs/** -host.example.com-error_log
Customlog D:/logs/** -host.example.com-access_log common
Jkmount/*. jsp work2
Jkmount/* work2
</Virtualhost>

2. Works. properties content

Workers. tomcat_home = D: \ tomcat5
Workers. java_home = c: \ jdk1.5
PS = \
Worker. List = work1, work2
Worker. work1.port = 8009
Worker. work1.host = 127.0.0.1
Worker. work1.type = ajp13
Worker. work1.lbfactor = 1

Worker. work2.port = 8014
Worker. work2.host = 127.0.0.1
Worker. work2.type = ajp13
Worker. work2.lbfactor = 1

3. Modify the host name attribute in Tomcat server. xml configuration:

<Host name = "www. ****. com" DEBUG = "0" appbase = "MyApp" reloadable = "true">

[Mrzho ]:
Agree with the previous answer, mainly configured in the settings of works. properties and virtualhost. Because Tomcat can also be switched based on the domain name, the corresponding host should also be set in Tomcat.

[Gong43 ]:
I believe on the HTTP. conf, you shoshould also specify the location of the file workers. properties.

[Guagua321 ]:
There are many experts here. Contact me.
Highly-paid senior Java programmers
Work Location: Beijing
More than three years of Java Development Experience (J2EE, EJB, system design and analysis)
Contact: Mail guagua2008@tom.com, someone will contact you soon

[Cm4ever ]:
Tomcat4 (Tom). Do not set any environment variables of Catalina or tomcat in the system, so Tomcat will use startup. BAT/startup. the directory started by SH is used as the environment variable catalina_base and catalina_home.

[Cm4ever ]:
This is the parent directory of the Directory started by startup. BAT/startup. Sh.

[Mrzho ]:
<Virtualhost *: 80>
Serveradmin xxx@xxx.com
Proxypass/AJP: // localhost: 8009/
Proxypassreverse/AJP: // localhost: 8009/
Servername www.xxx.com
......
</Virtualhost>
<Virtualhost *: 80>
Serveradmin yyy@yyy.com
Proxypass/AJP: // localhost: 8049/
Proxypassreverse/AJP: // localhost: 8049/
Servername www.yyy.com
......
</Virtualhost>

[Iohui ]:
Bangding

[Fangtaohbjjxy ]:
. Ding

[Colinmok ]:
Help !!
I 'd like to use it for a moment: I'm a good downloading master.
On the same server (Public IP address), tomcat5.0, two existing domain names point to this IP address. How do I configure tomcat?
TKs!

[Cm4ever ]:
This post has been on top for a long time. I came back to visit it and said mod_jk2 and Apache has stopped updating mod_jk2 for a long time:

Http://www.apache.org/dist/tomcat/tomcat-connectors/jk2/

Mod_jk continue

Http://www.apache.org/dist/tomcat/tomcat-connectors/jk/

[Liusoft ]:

Http://www.dlog.cn/html/diary/showlog.vm? SID = 2 & log_id = 4780

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.