My understanding of apache + tomcat + jk2 integration

Source: Internet
Author: User
Article Title: let's talk about my understanding of apache + tomcat + jk2 integration. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Apache and tomcat can be used as independent WEB servers. apache is powerful and efficient, but does not support JSP and serlet. tomcat is the opposite, so we need to combine them.
  
By loading and setting the integration module in apache, apache can forward requests that do not belong to itself to tomcat based on the url.
  
Relevance of version selection:
------------------------------------------------------------------------------
1. Apache
Httpd2.0.x: I don't know the difference between httpd2.0.x and apache1.3.x. it should be a leap. I have changed my name to httpd. We chose JK2 integration. JK2 was developed for the idea of apache2.0 (poor English, see the original article: JK2 has been developed with Apache 2.0 in mind), so we chose to use httpd2.0.x.
  
2. integration method-JK2
Why choose JK2? (JK is a replacement to the elderly mod_jserv. it was a completely new Tomcat-Apache plug-in that handles the communication between Tomcat and Apache. the newest JK2 is a refactoring of JK. the native part has been completly restructured and the configuration has been simplified a lot .) there are still many detailed descriptions, but I only understood the last sentence.
  
3. Tomcat5.0, J2SDK1.4. x
Can it support newer JAVA, JSP, and Servlet standards? There should be a certain correlation between them. it is said that tomcat5 and JDK1.4 have improved their support for Chinese, and no complicated settings are required, however, the Chinese compatibility of pages developed based on JSP standards is not good.
  
Notes during compilation and installation:
-------------------------------------------------------------------------------
1. Apache
It must be compiled to allow dynamic loading of modules, that is, the -- enable-so option must be added to configure, because the mod_jk2 integration module will be loaded in the future.
If the installation directory of apache is PathofApache, the compiled module is under PathofApache/modules, and the configuration file is under PathofApache/conf.
  
2. tomcat
Only the binary version is used. extract and release the package. (I heard that tomcat is written in JAVA. I don't know the advantages of compiling with that ANT, and I haven't tried it.) assume that the tomcat installation directory is PathOfTomcat.
  
3. JDK
I use the binary version and run it directly. decompress and release the package. (If you use that RPM package, I don't know how to set JAVA_HOME.) set JAVA_HOME and CLASSPATH environment variables. JAVA_HOME is not set but assigned a value in PathOfTomcat/bin/catalina. sh. CLASSPATH is not set yet. it may be used when JAVA standard classes are used in JSP.
  
4. JK2 module compilation
Assume that after the JK2 package is released, the directory is changed to PathOfJK2 and the current directory is PathOfJK2. (refer to the JK documentation. Note that the compiling part is described in JK, but the JK2 part should be omitted, because different integration methods are quite different. Http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/
)
  
Cd jk/native2
  
Chmod + 755 buildconf. sh
./Buildconf. sh)
  
./Configure -- with-apxs2 = PathOfApache/bin/apxs
This apxs is in the bin of the apache installation directory, so apache must be installed first. It is said that this file is only available for the compiled and installed apache. This file is not available for the rpm Package. if you want to install the apache compilation integration module for the rpm Package, find the same version for compilation and then delete it. the version number must be identical. Otherwise, the compiled module cannot be used.
There are two other parameters I don't know, and I don't know much about the English description. it is described in JK's document: -- with-apache = DIR, DIR is the path where apache sources are located. the apache sources shocould have been configured before login ing mod_jk. DIR is something like:/home/apache/apache_1.3.19 It builds a static Apache module. -- enable-EAPI, This parameter is needed when using Apache-1.3 and mod_ssl, otherwise you will get the error message: "this module might crash u Nder EAPI! "When loading mod_jk.so in httpd. Not needed when -- with-apxs has been used
  
In addition, when I run configure, the system prompts an error, as if it was about the path. then I started tomcat and ran it.
Make
Make install
  
All documents indicate that if the release is unsuccessful, it should be released manually. I also published it manually:
Cp PathOfJK2/build/jk2/apache2/mod_jk2.so PathOfApache/modules/
  
Configuration file modification
-------------------------------------------------------------------------------
JK2 uses two configuration files:
Jk2.properties, which is put in PathOfTomcat/conf by default
Workers2.properties should be placed in PathOfApache/conf by default.
The roles of these two files are really unclear. jk2.properties may define the communication ports between tomcat and apache. workers2.properties may tell apache which directories are supported by tomcat.
  
1. in PathOfTomcat/conf, the main configuration files of tomcat are server. xml and JK2, jk2.properties.
In fact, I have not made any changes to these two files, and jk2.properties is empty by default. I looked at the function of server. xml, which may be followed by the first one. it is useful for integration. it should not be added.
  
   Protocol = "AJP/1.3" type = "codeph" text = "/codeph"/>
  
2. in the PathOfApache/conf file, there is the apache configuration file httpd. conf and the JK2 configuration file workers2.properties.
Modify httpd. conf and add only LoadModule jk2_module modules/mod_jk2.so.
For details about workers2.properties, the minimum configuration in the JK document example is as follows:
# Define the communication channel
[Channel. socket: localhost: 8009]
Info = Ajp13 forwarding over socket
TomcatId = localhost: 8009
  
# Map the Tomcat examples webapp to the Web server uri space
[Uri:/examples/*]
Info = Map the whole webapp
  
In this way, the entire method is completed. as long as the/examples directory is accessed normally, this directory can be transferred to tomcat by apache without adding the tomcat port number.
This may be the simplest but rarely used configuration method.
--------------------------
  
Another configuration method is very practical but not understandable. it is suitable for many virtual hosts.
Use apache and tomcat as virtual hosts and direct the same host to the same root directory.
If Port jk2.properties is not changed, it can be null, and workers2.properties does not require address ing (?).
  
Add again in http. conf
  
Order allow, deny
Deny from all
  
# Because it is the same directory, the access to the WEB-INF is prohibited.
  
  
JkUriSet worker ajp13: localhost: 8009
  
# This may be a Ing. the jsp and servlet in the directory are parsed by tomcat.
  
In addition to virtual hosts, server. xml may need to be added
  

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.