A New Approach to Apache and Tomcat Integration

Source: Internet
Author: User

Purpose:
  
Use apache as the front-end of two tomcat servers and forward the client request and server reponse.
  
Apache address: 10.194.0.131
  
Tomcat server address: 10.11.1.29, 10.11.1.2
  
  The configuration steps are as follows:
  
  1. Download the source code of the new versions of Apache 2.0.54 and Tomcat Connector 1.2.14.1, compile and install Apache and Connector:
  
1. Run BuildConf, Configure -- prefix =/usr/local/Apache2.0.54, make, and make install in the Apache source code directory to install Apache in the/usr/local/Apache2.0.54 directory.
  
2. run BuildConf and Configure -- with-apxs =/usr/local/Apache2.0.54/bin/apxs, make, and make install in jk/native/of the Connector source code directory, install mod_jk.so in the/usr/local/Apache2.0.54/modules directory.
  
  Ii. Configure apache:
  
1. Configure the workers attribute file: Create the workers. properties file in the conf directory of apache. The content is as follows:
  
Ps =/worker. list = worker1, jvm1worker. worker1.port = 8009worker. worker1.host = 10.11.1.29worker.worker1
. Type = ajp13worker. worker1.socket _ keepalive = trueworker. jvm1
. Port = 8009worker. jvm1.host = 10.11.1.2worker.jvm1
. Type = ajp13worker. jvm1.socket _ keepalive = true
  
2. Configure httpd. conf:
  
Add the following content to the LoadModule configuration section:
  
LoadModule jk_module modules/mod_jk.so # Where to find workers. propertiesJkWorkersFile/usr/local/apache2.0.54/conf/workers. properties # Where to put jk logsJkLogFile
/Usr/local/apache2.0.54/mod_jk.log # Set the jk log level [debug/error/info] JkLogLevel
Info # Select the log formatJkLogStampFormat
"[% A % B % d % H: % M: % S % Y]" # JkOptions indicate to send SSL KEY SIZE, JkOptions
+ ForwardKeySize + ForwardURICompat-ForwardDirectories # JkRequestLogFormat set the request format JkRequestLogFormat "% w % V % T"
  
Configure the following content in VirtualHost:
NameVirtualHost *: 80
ServerAdmin webmaster @ demo
ServerName 10.11.1.29
DirectoryIndex index. jsp index.html
  
  
JkMount/* worker1
ServerAdmin webmaster @ print
ServerName 10.11.1.2
  
  
JkMount/* jvm1
  
  3. Configure tomcat:
  
1. Modify the server. xml file 10.11.1.29:
  
Find ... Add the jvmRoute attribute:
  
   ...
  
2. Modify the server. xml file of 10.11.1.2:
  
Find ... Add the jvmRoute attribute:
  
   ...
  
   Iv. Extended functions:
  
You can configure multiple tomcat servers for the same web application and use the server Load balancer feature of apache to achieve load balancing among multiple servers for the same web application, improve web access efficiency. The example in this article does not implement this feature. Try it by yourself according to the document.

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.