Installing Tomcat5 on RHEL4 or CentOS4.2 or Centos 5
November 25th, 2007First, you’ll need some base packages that you may not have already installed.
yum install rpm-build gcc-java |
If you’re in North America, create a new yum repository file containing lines like the following:
[jpackage16-generic]name=JPackage 1.6 Genericbaseurl= ftp://jpackage.hmdc.harvard.edu/JPackage/1.6/generic/free/ gpgcheck=1[jpackage16-rhel40] name=JPackage 1.6 for Red Hat Enterprise Linux 4 baseurl=ftp://jpackage.hmdc.harvard.edu/JPackage/1.6/ \ redhat-el-4.0/free/gpgcheck=1 |
If you live outside of North America, please use the closest mirror.
Next, you’ll need to import the Jpackage GPG key:
rpm --import http://www.jpackage.org/jpackage.asc |
Get some SRPMs for building the non-free packages. I like installing these to /usr/local/src on Linux systems. If you prefer another directory (/tmp works well) use it instead.
cd /usr/local/srcwget ftp://jpackage.hmdc.harvard.edu/JPackage/ 1.6/generic/non-free/SRPMS/java-1.4.2-sun-1.4.2.09-1jpp.nosrc.rpm wget ftp://jpackage.hmdc.harvard.edu/JPackage/1.6/generic/non-free/SRPMS/jta-1.0.1-0.b.4jpp.nosrc.rpm |
Download some required files to /usr/src/redhat/SOURCES
- download jta-1_0_1B-classes.zip here after agreeing to license.
- download j2sdk-1_4_2_09-linux-i586.bin here after agreeing to license.
This page was last updated on 2005-10-02. You might have to poke around on the to find the right files if Sun has changed those pages too much.
Build and install the non-free packages.
rpmbuild --rebuild /usr/local/src/ \ java-1.4.2-sun-1.4.2.09-1jpp.nosrc.rpmrpm -ivh \ /usr/src/redhat/RPMS/i586/java-1.4.2-sun-1.4.2.09-1jpp.i586.rpmrpm -ivh /usr/src/redhat/RPMS/i586/ \ java-1.4.2-sun-devel-1.4.2.09-1jpp.i586.rpmrpmbuild --rebuild --without javadoc /usr/local/src/ jta-1.0.1-0.b.4jpp.nosrc.rpm \rpm -ivh /usr/src/redhat/RPMS/noarch/jta-1.0.1-0.b.4jpp.noarch.rpm |
And finally, install the free packages
yum install tomcat5 tomcat5-admin-webapps |
“Tim N.” has written to suggest that the above “yum install” line needs to also include “tomcat5-webapps”. I’d imagine it really depends on whether you have dependence on the non-admin webapps or not. However, if you have problems or know you want the non-admin apps, you probably will want to install the “tomcat5-webapps” package as well.
Original Source from : http://www.tummy.com/Community/Articles/tomcat-centos/
Now we create the ’service’ of tomcat5
Create file /etc/init.d/tomcat5
#!/bin/sh
#
# Startup script for jakarta tomcat 5.5.25
#
# chkconfig: - 85 20
# description: Tomcat running
# processname: tomcat
# pidfile: /var/run/tomcat.pid # config:# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0# Set Tomcat environment.
export JAVA_HOME=/usr/lib/java/
export CLASSPATH=.:/usr/java/lib/tools.jar:/usr/lib/java/j2re/lib/rt.jar
export CATALINA_HOME=/usr/lib/tomcat5
export CATALINA_OPTS="-Dbuild.compiler.emacs=true"
export PATH=/usr/lib/java/j2sdk/bin:/usr/lib/j2re/bin:$PATH
[ -f /usr/lib/tomcat5/bin/startup.sh ] || exit 0 [ -f /usr/lib/tomcat5/bin/shutdown.sh ] || exit 0
export PATH=$PATH:/usr/bin:/usr/lib/bin
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n "Starting Tomcat: "
/usr/lib/tomcat5/bin/startup.sh
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat ;;
stop)
# Stop daemons.
echo -n "Shutting down Tomcat: "
/usr/lib/tomcat5/bin/shutdown.sh
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat ;;
restart)
$0 stop
$0 start
;;
condrestart)
[ -e /var/lock/subsys/tomcat5 ] && $0 restart ;;
status)
status tomcat
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
And then make this above script executable and add it on chkconfig
# chown root:root /etc/rc.d/init.d/tomcat
# chmod 755 /etc/rc.d/init.d/tomcat
# chkconfig --add tomcat
# chkconfig tomcat on
# service tomcat start