LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-07-2006, 04:03 AM   #1
bascule
LQ Newbie
 
Registered: Feb 2006
Distribution: FC4
Posts: 5

Rep: Reputation: 0
getting Tomcat to run on boot in Fedora 4


Hi

I've installed Tomcat and Java successfully on my Fedora Core 4 system. I can run startup.sh and see the default Tomcat page on 127.0.0.1:8080.

I now want Tomcat to run on boot, so I've been looking around at how to do this and I've ended up doing the following:

1. Added the following lines to /etc/rc.d/rc.local:

#start Tomcat
sh /home/phil/apache-tomcat-5.5.15/bin/startup.sh


2. Created a symbolic link called "K06tomcat" in /etc/rc.d/rd5.d which points to "/home/phil/apache-tomcat-5.5.15/bin/shutdown.sh" - the idea here is that this gets called on shutdown to stop Tomcat - actually, this is a side issue, is this an appropriate way to do this? - I picked the lowest number available (i.e. from K01, K02...) to name the link with hoping it would get called as soon as possible.



3. Added the following lines to /etc/profile (above the already existing 'export' command):

JAVA_HOME=/usr/java/jdk1.5.0_06
CATALINA_HOME=/home/phil/apache-tomcat-5.5.15


4. Added the following line to ~/.bash_profile:

export JAVA_HOME=/usr/java/jdk1.5.0_06


When Fedora starts up, I get the error message complaining that "neither JAVA_HOME nor JRE_HOME" are defined - this comes from setclasspath.sh, so somehow the environment variables are not being set by either of the two scripts before this is executed, or it's not 'in scope' or something?

For the record, if I hardcode JAVA_HOME in to the top of setclasspath.sh, Tomcat works ok on boot, but I don't want to do that, I want it to use the environment variables.
 
Old 02-07-2006, 08:52 AM   #2
barrulus
LQ Newbie
 
Registered: Feb 2006
Location: Wales
Distribution: Fedora, SuSE, CentOS, Ubuntu
Posts: 13

Rep: Reputation: 0
use the following:
(save this as /etc/init.d/tomcat)
[snip]
#!/bin/sh
# chkconfig: 3 90 90
# description:Tomcat JSP server
export JAVA_HOME=/usr/local/java
export CATALINA_OPTS="-Xms128m -Xmx756m -Djava.awt.headless=true"
rm -rf /usr/local/tomcat/work/Catalina/localhost/mimecast
case "$1" in
start)
echo -n "Starting Tomcat:"
cd /usr/local/tomcat/bin/
./startup.sh
echo
;;
stop)
echo -n "Stopping Tomcat"
cd /usr/local/tomcat/bin/
./shutdown.sh
echo
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage:$0{start|stop|restart}"
exit 1
esac
exit 0
[/snip]

Ok, in this startup script I have specified what my java environment variable is (/usr/local/java) as I do not use the default system java.
I install java into /usr/java/j2sdk etc, then symlink to /usr/local/java as that way I can add new java, change my symlink, test and if not good just chnage the symlink again...

export CATALINA_OPTS="-Xms128m -Xmx756m -Djava.awt.headless=true"
This line says: run with 128MB RAM, but use a MAX of 756MB RAM, and that it must run as a daemon.


You will also not that I (again, symlink is your friend) symlink /usr/local/tomcat to /usr/local/jakarta_tomcat....etc
Again this is so I can upgrade tomcat with a very very short downtime and very easy rollback in the advent of a problem.

Don't forget to add tomcat to your startup using chkconfig (chkconfig --add tomcat; chkconfig --level 3 tomcat on) , and don't forget to change the permissions of the file /etc/init.d/tomcat, this must be 755 (chmod 755 /etc/init.d/tomcat)

I hope this helps.
 
Old 02-07-2006, 11:57 AM   #3
bascule
LQ Newbie
 
Registered: Feb 2006
Distribution: FC4
Posts: 5

Original Poster
Rep: Reputation: 0
That's worked really well, thanks.

Also, I like the use of the symlinks - that's neat solution to changing versions of java/tomcat etc.

Thanks a lot!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to run Tomcat 5.5.9 on Fedora core 4 tech_j Linux - Software 2 09-04-2005 09:17 AM
I can't run tomcat hus Programming 2 05-11-2005 11:48 AM
How do you run Tomcat as nobody? vous Linux - Software 11 03-24-2005 01:15 PM
How do I make a command run as root at boot up under Fedora 3? versaulis Linux - Software 5 02-10-2005 06:22 PM
How to start scriptfile(tomcat) automatically at boot-time run fmohideen76 Linux - General 4 07-11-2002 10:44 PM


All times are GMT -5. The time now is 10:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration