Jakarta-Tomcat 


1. Create a directory for the Tomcat download and set the JAKARTA_HOME variable with the following commands:

mkdir /usr/local/jakarta_3.2.3
cd /usr/local/jakarta_3.2.3
JAKARTA_HOME=/usr/local/jakarta_3.2.3
export JAKARTA_HOME 

2. Go to Jakarta site http://jakarta.apache.org/builds/tomcat and download binary tars ${JAKARTA_HOME} using the following commands:

wget http://jakarta.apache.org/builds/tomcat/release/v3.2.3/bin/jakarta-servletapi-3.2.tar.gz
wget http://jakarta.apache.org/builds/tomcat/release/v3.2.3/bin/jakarta-tomcat-3.2.3.tar.gz 
3.Uncompress the following tars:
tar -xzvf jakarta-servletapi-3.2.tar.gz

tar -xzvf jakarta-tomcat-3.2.3.tar.gz 
4.Reset the environment variables as follows: 

JAVA_HOME=/usr/local/jdk1.3 
export JAVA_HOME 
PATH=/usr/local/bin:${JAVA_HOME}/bin:${PATH} 
export PATH 
CLASSPATH=${JAVA_HOME}/lib/tools.jar:${JAVA_HOME}/lib/dt.jar 
export CLASSPATH 
JAKARTA_HOME=/usr/local/jakarta_3.2.3 
export JAKARTA_HOME 
TOMCAT_HOME=${JAKARTA_HOME}/jakarta-tomcat-3.2.3 
export TOMCAT_HOME 

5.To use Tomcat with Apache, you need the mod_jk or mod_jserv modules. These modules allow Apache to talk to the Tomcat servlet container via TCP socket. 

6.If you cannot find binary mod_jk for Tomcat, you may compile the mod_jk module using the source code. Compile the mod_jk use this: 

cd ${JAKARTA_HOME}
wget http://jakarta.apache.org/builds/tomcat/release/v3.2.3/src/jakarta-tomcat-3.2.3-src.tar.gz
tar -xzvf jakarta-tomcat-3.2.3-src.tar.gz 
cd ${JAKARTA_HOME}/jakarta-tomcat-3.2.1-src/src/native
cd apache1.3
/usr/local/apache/bin/apxs -o mod_jk.so \
-I${JAVA_HOME}/include/linux \
-I../jk -I${JAVA_HOME}/include \
-c *.c ../jk/*.c
cp mod_jk.so /usr/local/apache/libexec/


7.Test tomcat standalone. Move all files which are in /usr/local/jakarta_3.2.3/jakarta-tomcat-3.2.3/conf/ to this directory:
cd $TOMCAT_HOME/conf 

mkdir original-conf 
mv * original-conf 
cd original-conf 
cp server.xml .. 
cp web.xml .. 
cp workers.properties .. 
cp tomcat-users.xml .. 
Then copy what you need back to the /usr/local/jakarta_3.2.3/jakarta-tomcat-3.2.3/conf/ directory. 

8.Edit ${TOMCAT_HOME}/conf/server.xml and add a connector for protocol ajp13 to port 8006. To do this add the following code: 

<!-- Apache AJP13 support -->
<Connector className="org.apache.tomcat.service.PoolTcpConnector">
<Parameter name="handler"
value="org.apache.tomcat.service.connector.Ajp13ConnectionHandler"/>
<Parameter name="port" value="8006"/>
</Connector> 
Keep the ajp12 connector, even if you do not use it. You will need it to shut down Tomcat. Also, change all the docbases to context tags with full paths, e.g.:

docBase="webapps/examples" 
to
docBase="/usr/local/jakarta_3.2.3/jakarta-tomcat-3.2.3/webapps/examples

9.Create the following directory for testing:
mkdir /home/www/

mkdir /home/www/html/ 
mkdir /home/www/html/examples-test 
And, unpack examples.war files using this code (context is not in a default location): 

${TOMCAT_HOME}/webapps. 
cd /home/www/html/examples-test 
jar xvf ${TOMCAT_HOME}/webapps/examples.war 

10.Mount examples-test directory in ${TOMCAT_HOME}/conf/server.xml. 

Server.xml is the file Tomcat reads to configure itself. 
Tomcat does not use any information from workers.properties or mod_jk.conf to configure itself. 
These are meant for Apache or other Web severs with which Tomcat works.

The files for mod_jk module of Apache are mod_jk.conf and workers.properties. For the time being, test if Tomcat works alone by starting it:
cd ${TOMCAT_HOME}/bin

./startup.sh 
11.Attempt to see Tomcat in your browser: 

http://your.machine:8080/ 

12.Try some examples, http://your.machine:8080/examples/jsp, etc. If you think there are problems, shutdown Tomcat using the following command: 

cd ${TOMCAT_HOME}/bin 
./shutdown.sh 

And check to see if ports 8080 and 8007 are occupied by something else. List ports as: 

netstat -a -n | grep -i listen 

Before configuring the files, you should shutdown Tomcat using this command: 

./shutdown.sh 

13.After testing Tomcat, the configuration file for mod_jk for Apache is automatically created: 

Cd $TOMCAT_HOME/conf/mod_jk.conf 
mv mod_jk.conf-auto mod_jk.conf 

14.Edit the Apache configuration file, httpd.conf, located in: 

cd /usr/local/apache/conf/ 

Add mod_jk.conf at the end of httpd.conf file above so that it reads: 

Include /usr/local/jakarta_3.2.3/jakarta-tomcat-3.2.3/conf/mod_jk.conf 

15.Edit the mod_jk.conf and replace all occurrences of ajp12 with ajp13. 

16.Make the following changes to the $TOMCAT_HOME/conf/workers.properties file. Change workers.tomcat_home, workers.java_home, ps, and worker.ajp13.port ports to 8006. Also comment out all inprocess definitions, as Tomcat does not run inprocess within Apache. 

Example: 

workers.tomcat_home=$TOMCAT_HOME/ 
workers.java_home=$JAVA_HOME 
ps 
Windows ps=\ 
Linux ps=/ 
worker.ajp13.port=8009 

Note, the ajp12 port is 8007 and ajp13 is 8009. 

17.Start Tomcat using this command: 

cd $TOMCAT_HOME/bin
./startup.sh


18.Start Apache using this command:
/usr/local/apache/bin/apachectl start
19.Test the synchronization of the two servers using these addresses (use either Netscape or Internet Explorer): 

http://your.machine/examples/jsp/ 
http:// your.machine/examples-test/jsp/ 

20.Continue reconfiguring Tomcat and Apache. In /usr/local/apache/conf/httpd.conf, make sure mod_jk appears before mod_rewrite. For example: 

LoadModule jk_module libexec/mod_jk.so
LoadModule rewrite_module libexec/mod_rewrite.so


and
AddModule mod_jk.c

AddModule mod_rewrite.c 
21. Edit the $TOMCAT_HOME/conf/mod_jk.conf file. Comment out the line:


# LoadModule jk_module libexec/mod_jserv.so
22. This completes the installation and configuration.