|
|||
HOWTO : Apache2, Mod_JK2, Tomcat 4.1.24 and JDK 1.4 on RedHat Linux 7.3 : JNI | |||
00. intro | |||
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 --enable-module=so make make install |
|||
A version of Apache2 should now be in /usr/local/apache2. You should now test the default config by using | |||
/usr/local/apache2/bin/apachectl configtest | |||
If the test returns "Syntax OK", you should start up Apache2 to verify it's operation | |||
/usr/local/apache2/bin/apachectl start | |||
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. |
|||
export CATALINA_HOME='/usr/local/tomcat' |
|||
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. http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk2/release/v2.0.2/src/ <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... |
|||
./configure \ --with-apxs2=<apache-root-directory>/bin/apxs \ --with-tomcat41=<tomcat-root-directory> \ --with-java-home=<java-root-directory> \ --with-jni \ --with-pcre |
|||
An example configure statement might look like this... | |||
./configure --with-apxs2=/home/apache/bin/apxs \ --with-tomcat41=/home/tomcat \ --with-java-home=/usr/java \ --with-jni \ --with-pcre |
|||
Finally, run make |
|||
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... /usr/local/Apache2/modules |
|||
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. # # Example: # 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... http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/jk2/configtc.html http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/jk2/configtccom.html To help you get started, here is the workers2.properties file for my system. TODO: add virtual hosting to config |
|||
# workers2.properties [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 # handler.list=apr,request,channelJni # # Override the default port for the socketChannel # channelSocket.port=8019 # Default: # channelUnix.file=${jkHome}/work/jk2.socket # Just to check if the the config is working #shm.file=/usr/local/Apache2/logs/jk2.shm # In order to enable jni use any channelJni directive channelJni.disabled = 0 # And one of the following directives: # apr.jniModeSo=/opt/apache2/modules/mod_jk2.so # If set to inprocess the mod_jk2 will Register natives itself # This will enable the starting of the Tomcat from mod_jk2 apr.jniModeSo=inprocess |
|||
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" that share |
|||
08. Credits | |||
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. http://www.gregoire.org/howto/Apache2_Jk2_TC4.1.x_JSDK1.4.x.html http://marc.theaimsgroup.com/?l=tomcat-user&m=105103815630094&w=2 http://www.johnturner.com/howto/rh72-howto.html |
|||
Last updated on 06.04.2003 |