Next: 20 KRUD Updates
Up: Redhat FAQ
Previous: 18 Time Services
Contents
Subsections
- By:
- Stephen Carville
- Rev:
- 08/26/03
- From local ftp or from the Jakarta Project Web Site download the latest
stable versions of Ant, and Tomcat. Because we are interested in the
developing Server Side Includes (SSI) rather than hacking the technology,
the binaries are perfectly good.
- Create a directory for the Jakarta software. Here we use /var/jakarta.
- Change to the newly created directory.
- As necessary, extract the jakarta-ant and jakarta-tomcat archives
to this directory.
- Create some useful symlinks
# ln -s jakarta-ant-<version> ant
# ln -s jakarta-tomcat-<version tomcat
- If necesary source the changes in the Java setup script
- Start the tomcat server
# /var/jakarta/tomcat/bin/startup.sh
- If no errors are reported open a browser and connect to port 8080.
- Shutdown the tomcat server
# /var/jakarta/tomcat/bin/startup/shutdown.sh
- Make any necessary changes to the configuration
- Create a startup script so tomcat is started as a service at boot.
(See: 19.3)
19.1 Using mod_jk
- Make certain axps is installed. This is part of the apache-devel package
- Extract the archive
$ tar -xvzf jakarta-tomcat-connectors-jk-<version>-src.tar.gz
- Change to the the native directory
$ cd jakarta-tomcat-connectors-jk-<version>-src/jk/native
- Run the buildconf script
$ ./buildconf.sh
- Run the configure script
$ ./configure -with-apxs=/usr/sbin/apxs
- Make the module
$ make
- Copy the module to the Apache modules directory
$ sudo cp apache-1.3/mod_jk.so /etc/httpd/modules/.
This is not necessary on Linux but I usually have to do it this way
on Solaris
- Change to the native directory
$ cd jakarta-tomcat-connectors-jk-<version>-src/jk/native
- Build using apxs
$ apxs -o mod_jk.so -Icommon -I/usr/java/jdk/include usr/java/jdk/include/solaris
-c apache-1.3/*.c common/*.c
- Copy the module to the Apache modules directory
$ sudo cp mod_jk.so /etc/httpd/modules/.
- Change to the apache configuration directory
$ cd /etc/httpd/conf
- Create a workers.conf file containing at a minimum:
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.
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
- Add to httpd.conf:
LoadModule jk_module modules/mod_jk.so
# Declare the module for <IfModule directives>
AddModule mod_jk.c
# Where to find workers.properties
JkWorkersFile /etc/httpd/conf/workers.conf
# Where to put mod_jk logs
JkLogFile /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
- Restart Apache
Alias /cert/ /var/jakarta/tomcat/webapps/cert/
<VirtualHost *>
ServerName www.dpsi-corp.com
DocumentRoot /var/jakarta/dpsi-corp/ROOT
DirectoryIndex HomePage.jsp index.html
JkMount /*.jsp worker1
</VirtualHost>
- Create an AJP 1.3 connector
<!- Define an AJP 1.3 Connector on port 8009 ->
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009"
minProcessors="5"
maxProcessors="75"
acceptCount="10"
debug="0"
/>
- Restart tomcat
<Host name = "www.dpsi-corp.com" debug =
"0"
appBase="/var/jakarta/dpsi-corp">
<Context path="" docBase="ROOT"
/>
</Host>
This is not a good solution but is sometimes necessary. If possible
use mod_jk and Apache (See: 19.1)
- Create a sub interface with a different IP address (See: 8.1.1)
- Make a copy of the tomcat directory
$ cp -r jakarta-tomcat-<version> jakarta-tomcat-<version>-2
- Symlink the new directory to a new name
$ ln -s jakarta-tomcat-<version>-2 tomcat-2
- Edit <tomcat-directory>/conf/server.xml to add an address and change
the shutdown port and the AJP port. Some examples:
<Server port="8005" shutdown="SHUTDOWN"
debug="0">
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
address="192.168.124.221" port="80"
minProcessors="5" maxProcessors="75"
enableLookups="true"
redirectPort="8443"
acceptCount="10" debug="0"
connectionTimeout="20000"
useURIValidationHack="false" />
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009"
minProcessors="5" maxProcessors="75"
enableLookups="true"
redirectPort="8443"
acceptCount="10" debug="0"
connectionTimeout="20000"
useURIValidationHack="false" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
- Create a startup file with the differences between the two installs.
This will usually only be TOMCAT_HOME and CATALINA_HOME. For example:
#! /bin/bash
# set up for tomcat-2
# source the regular tomcat stuff
. /etc/java.sh
# changes for tomcat-2
TOMCAT_HOME=$JAKARTA_HOME/tomcat-2
CATALINA_HOME=$JAKARTA_HOME/tomcat-2
export CATALINA_HOME TOMCAT_HOME
19.3 Example Tomcat Startup Script
#! /bin/bash
# # Startup script for the Tomcat Server
# be certain the start and stop priority for chkconfig
# starts tomcat before httpd and the runlevel list matches
httpd.
# Otherwise, apache may choke. Shutdown is less important
#
# chkconfig: 345 80 20
# description: starts and stop the tomcat java server
#
SU=/bin/su
USER=tomcat
# source tomcat stuff
. /etc/java.sh
start() {
echo -n "Starting tomcat: "
$SU - $USER -c $TOMCAT_HOME/bin/startup.sh
RTNVAL=$?
return $RTNVAL
}
stop() {
echo -n "Shutting down tomcat: "
$SU - $USER -c $TOMCAT_HOME/bin/shutdown.sh
RTNVAL=$?
return $RTNVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
Next: 20 KRUD Updates
Up: Redhat FAQ
Previous: 18 Time Services
Contents
2005-03-20