Linux Blog

Using a custom Tomcat on Fedora

Filed under: Quick Linux Tutorials — TheLinuxBlog.com at 10:22 am on Wednesday, November 12, 2008

So, I hear you need to use Tomcat on Fedora eh? Not happy with the available Tomcat version from the repository? Well my friends you can add a custom Tomcat to Fedora and have it run as a service.

This post is somewhat related to: my Adding a service on Fedora post except this one is more specific to Tomcat. If you’d like more information on adding services to Fedora that is the place to look.

Here is the script that I have been using:

#!/bin/bash
#
# tomcat       Startup script for the tomcat server
# chkconfig: - 07 93
# description: tomcat
# processname: tomcat
#
### BEGIN INIT INFO
# Provides: tomcat
# Short-Description: start and stop the tomcat server
# Description: Tomcat Server Located in /opt/tomcat/
### END INIT INFO
 
# Source function library.
 
# Next line not needed - Starting tomcat defined in startup.sh
# prog="tomcat"
 
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure.  So we just do it the way init scripts
# are expected to behave here.
start() {
#        echo -n $"Starting $prog: "
/opt/tomcat/bin/startup.sh
}
 
# When stopping httpd a delay of >10 second is required before SIGKILLing the
# httpd parent; this gives enough time for the httpd parent to SIGKILL any
# errant children.
stop() {
echo -n $"Stopping $prog: "
/opt/tomcat/bin/shutdown.sh
}
reload() {
echo -n $"Reloading $prog: "
}
 
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart}"
RETVAL=3
esac
 
exit $RETVAL

It is very much the same as the standard service script. One thing that you need to be aware of is the java version that is running. Make sure that the correct one is running or you could suffer poor performance. You may want to change the chkconfig values so that it starts up sooner or later in the boot process. You can also enable the service at startup with ntsysv. Check out manage services on Fedora for other service options.

This post may be useful to some but its also a reference to myself. If you find it useful, please provide feedback so that I can update it! Thanks!





Random Man Pages:
fifo
void
ispell
SDL_MixAudio

1 Comment »

Comment by bill

July 31, 2009 @ 9:07 am

thanks, works great after removing the bollocks that windows puts instead of ”

I added the following to set my JAVA_HOME:

### BEGIN INIT INFO
# Provides: tomcat
# Short-Description: start and stop the tomcat server
# Description: Tomcat Server Located in /opt/tomcat/

JAVA_HOME=”/usr/java/jdk1.5.0_14″
export JAVA_HOME

### END INIT INFO

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>