|HOWTO : Apache2, Mod_JK2, Tomcat 4.1.24 and JDK 1.4 on RedHat Linux 7.3 : JNI|
This document will describe how to setup Apache2, Java JDK 1.4, Tomcat 4.1.x and ModJK2 on Redhat Linux 7.3. Tomcat will communicate with Apache2 using JNI and will be launched automatically when Apache2 is started. Even though RPMs are available, most of the components will be built from source. The exceptions being the JDK 1.4.1 RPM and Tomcat 4.1.24 from a binary tarball.
NOTE: THIS DOCUMENT IS AN ATTEMPT TO DOCUMENT MY CURRENT CONFIGURATION. I am still having problems using JNI, including "jk2_init() Can't find child xxxxx in scoreboard" and browser hangups while attempting to access Tomcat content. I have moved on to using TCP/IP sockets due to time constraints.
|01. install apache2|
Download Apache2 from www.apache.org. The latest version at the time of this document was Apache2.0.46.
<INSTRUCTIONS ON DOWNLOADING AND UNCOMPRESSING
THE APACHE2 TARBALL>
|./configure --prefix=/usr/local/apache2 --enable-ssl
|A version of Apache2 should now be in /usr/local/apache2. You should now test the default config by using|
|If the test returns "Syntax OK", you should start up Apache2 to verify it's operation|
|Open http://localhost in a browser, which should display the Apache welcome page.|
|02. install Jdk1.4.1|
|<JDK INSTALATION INSTRUCTIONS HERE>|
|03. INSTALL TOMCAT|
<TOMCAT INSTALLATION INSTRUCTIONS HERE>
Note: Tomcat will not be configured to run at boot time since Apache2 will launch it automaticlly when started.
Finaly, set CATALINA_HOME and TOMCAT_HOME to point to your Tomcat installation.
Add the following lines to /etc/profile.
|04. INSTALL / BUILD MOD JK2|
In this HOWTO, ModJK2 was built from source since a prebuild version was not yet avaliable on the Jakarta site. You can find the source tarball on the Apache website.
<explain how to decompress the archive into /user/local/src/jk2/>
The ModJK2 tarball uses Ant to build both the Java connectors for Tomcat and the native modules for Apache2. I was unable to use Ant to build ModJK2 but was successful building just the native components using make.
cd to /usr/local/src/jk2/jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2 and run configure with the following options...
|An example configure statement might look like this...|
|./configure --with-apxs2=/home/apache/bin/apxs \
Finally, run make
This will build mod_jk2.so and jkjni.so in jakarta-tomcat-connectors-jk2-2.0.2-src/jk/build/jk2/apache2
Copy these files into the modules directory of your Apache2 installation and restart Aapache. On my system, the modules directory was located at...
|05. configure apache2|
ModJk2 is a Apache module, which is loaded using the LoadModule command in <apache2 install>/conf/httpd.conf. The syntax for loading the module is as follows..
# Dynamic Shared Object (DSO) Support
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
# LoadModule foo_module modules/mod_foo.so
LoadModule jk2_module modules/mod_jk2.so
|While many of the required modJK2 commnads can be placed directly in httpd.config, we will define what content Apache should pass to Tomcat in the workers2.properties file.|
|06. Create Workers2.properties|
The workers2.properties file configures runtime options of ModJK2 and defines what content should be passed on to Tomcat. The syntax for this file is documented at...
To help you get started, here is the workers2.properties file for my system.
TODO: add virtual hosting to config
|Note: you may need to edit the paths in this file if you have installed Tomacat, Apache or the JDK in a different folder than suggested above.|
|06. create Jk2.properties|
|The file j2k.properties sets up the Tomcat side of the connection and where we configure Tomcat to run in process with Apache.|
|## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE
TOMCAT IS STOPED
## WHEN YOU EDIT THE FILE.
## COMMENTS WILL BE _LOST_
## DOCUMENTATION OF THE FORMAT IN JkMain javadoc.
# Set the desired handler list
# Override the default port for the socketChannel
# Just to check if the the config is working
# In order to enable jni use any channelJni directive
channelJni.disabled = 0
# And one of the following directives:
# If set to inprocess the mod_jk2 will Register natives itself
# This will enable the starting of the Tomcat from mod_jk2
|07. configure tomcat|
<GIVE BRIEF OVERVIEW OF TOMCAT CONFIG FILE>
Here is my trimmed down version of server.xml
<!-- A "Service" is a collection of one or more "Connectors"
Here are just a few of the many resources used while setting up Apache2 and Tomcat. Many thanks to those who have taken the time to provide these resources online.
|Last updated on 06.04.2003|