Linux Blog

Using a custom Tomcat on Fedora

Filed under: Quick Linux Tutorials — 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:

# tomcat       Startup script for the tomcat server
# chkconfig: - 07 93
# description: tomcat
# processname: tomcat
# Provides: tomcat
# Short-Description: start and stop the tomcat server
# Description: Tomcat Server Located in /opt/tomcat/
# Source function library.
# Next line not needed - Starting tomcat defined in
# 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: "
# 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: "
reload() {
echo -n $"Reloading $prog: "
# See how we were called.
case "$1" in
echo $"Usage: $prog {start|stop|restart}"
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!