Jakarta Tomcat 4.1.17 Notes
===========================
Install Apache 2.0.43
---------------------
%./configure --prefix=/usr/local/apache --sbindir=/sbin \
--datadir=/www/artkomichen --sysconfdir=/etc/apache --enable-so
The --enable-so option is the important note here to enable DSO support
% make
% make install
Setup Tomcat 4.1.17 / Ant / Apache / J2SDK
-------------------------------------------
* Download jakarta-tomcat, jakarta-ant, and mod_jk-2.0.42, and j2sdk-1_4_1
* Install all
% cd /usr/local
% tar xvfz tomcat-4.1.17.tar.gz
% tar xvfz jakarta-ant-1.5.1-bin.tar.gz
% ./j2sdk-1_4_0_01-linux-i586.bin
% cp mod_jk-2.0.42 /usr/local/apache/modules
% ln -s j2sdk1.4.0_01 jdk
% ln -s jakarta-ant-1.5.1 jakarta-ant
% ln -s jakarta-tomcat-4.1.17 jakarta-tomcat
# Setup Ant Tomcat development
% cp /usr/local/jakarta-tomcat/server/lib/catalina-ant.jar /usr/local/jakarta-ant/lib
* Change ~/.cshrc
setenv JAVA_HOME /usr/local/jdk
setenv CLASS_PATH /usr/local/jdk/lib:.:/usr/local/jakarta-tomcat/common/lib/servlet.jar
* Add directives to Apache for mod_jk
# Mod_Jk / Tomcat 4.1.17 Directives
LoadModule jk_module modules/mod_jk-2.0.42.so
JKWorkersFile /etc/apache/workers.properties
JkLogFile /www/logs/mod_jk.log
JkLogLevel info
JKLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
...
# Tomcat 4.1.12 / modjk settings
JkMount /explorer/* worker1
JkMount /explorer/*.jsp worker1
JkMount /explorer_old/* worker1
JkMount /explorer_old/*.jsp worker1
Notice that for mod_jk to work in this configuration, the name of JkMount must
be the same as the name of the servlet context (App name).
* Setup the /etc/apache.workers.properties file. The basic one looks like this. You can also setup load balancing here - look at the documentation for that.
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300
* Modify Tomcat /usr/local/jakarta-tomcat/bin/startup.sh and shutdown.sh files.
JAVA_HOME="/usr/local/jdk"
export JAVA_HOME
* Modify /usr/local/jakarta-tomcat/conf/tomcat-users.xml (This is so you can use the Manager app to work for development purposes).
* Copy the manager.xml file to your webapps directory
% cp /usr/local/jakarta-tomcat/webapps/manager.xml /www/streamlogic/webapps
* Modify the manager.xml file
* All right time to play with the server.xml file.
# Modify all the logger entries so it doesn't spam logs everywhere. Look
# for
# Enable MemoryRealm (which uses the conf/tomcat-users.xml file for user auth
# Enable a virtual host
# You can define contexts in here for specific apps but otherwise you can let things dynamically load
dev.artkomichen.com
* All Done! Startup tomcat and restart apache
% /usr/local/jakarta-tomcat/bin/startup.sh
% /sbin/apache stop
% /sbin/apahce start
* Not quite all done yet. Let's make our lives easier a bit:
* Add user/group tomcat (can't use nobody). Then go to /usr/local/tomcat
% chgrp -R tomcat temp logs work
% chown -R tomcat temp logs work
* Make tomcat part of mcstaff (in massconfusion's case) and make sure tomcat
has access to the log directories appropriately.
* Touch this file so tomcat user can do write to it
% touch /usr/local/jakarta-tomcat/conf/tomcat-users.xml.new
% chall tomcat /usr/local/jakarta-tomcat/conf/tomcat-users.xml.new
* Add bin/restart.sh
#!/bin/sh
su - tomcat -c "/usr/local/jakarta-tomcat/bin/shutdown.sh"
su - tomcat -c/usr/local/jakarta-tomcat/bin/startup.sh
* Add /etc/rc.d/init.d/jakarta-tomcat
#!/bin/sh
#
# chkconfig: 345 55 25
# description: Tomcat Servlet Server
#
# Tomact rc.d script
#
CLASSPATH="/usr/local/jdk/lib"
PATH="$PATH:/usr/X11R6/bin:/usr/local/jdk/bin:/usr/local/bin:/usr/bin:/bin"
export PATH CLASSPATH
mode=$1 # start or stop
case "$mode" in
'start')
su - tomcat -c "/usr/local/jakarta-tomcat/bin/startup.sh" 2>&1 > /www/logs/tomcat.log
;;
'stop')
su - tomcat -c "/usr/local/jakarta-tomcat/bin/shutdown.sh" 2>&1 > /www/logs/tomcat.log
;;
*)
# usage
echo "usage: $0 start | stop"
exit 1
;;
esac
* Add it to chkconfig
% chkconfig add jakarta-tomcat
* Getting the MySQL JDBC driver to work. There's evidently a bug so localhost
doesn't work for local JDBC connections You must add localhost.localdomain
(RedHat Bug). This applies to mysql-connector-java-2.0.14-bin.jar and Mysql
3.23.41 (it works fine on my 3.23.52 version):
mysql> insert into user
values('localhost.localdomain','web',PASSWORD('whatever'),'Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N');