LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-15-2006, 12:52 AM   #1
TrevorS
LQ Newbie
 
Registered: May 2006
Location: CT
Distribution: Slackware
Posts: 9

Rep: Reputation: 0
how to get Tomcat to run on startup?


Thank you to all of you who helped me get Slackware installed and running.

I just installed Apache Tomcat, and it runs fine, but I can't seem to get it to run on startup (boot up) of the machine. What else do I need to do?

Just like I did successfully with MySQL when I installed it, I added the following to /etc/rc.d/rc.M (after the code which launches Apache):

if [ -x /etc/rc.d/rc.tomcat ]' then
. /etc/rc.d/rc.tomcat start
fi

Manually, I created the rc.tomcat (owned by root:root with -rwxr-xr-x permissions) and it contains:

case "$1" in
'start')
/apache-tomcat-5.5.17/bin/startup.sh
;;
'stop')
/apache-tomcat-5.5.17/bin/shutdown.sh
;;
'restart')
/apache-tomcat-5.5.17/bin/shutdown.sh
sleep 3
/apache-tomcat-5.5.17/bin/startup.sh
;;
*)
echo "usage $0 start|stop|restart"
esac

Now, if I login as root and type "/etc/rc.d/rc.tomcat start" from the command line, Tomcat starts just fine. So I guess my script is okay. If I copy/paste the code piece inside rc.M into a temporary file and execute it, Tomcat starts fine. So why doesn't Tomcat startup automatically when I first boot the machine? What else do I need to do?

Is there a log file somewhere that I can look at? Nothing in /apache-tomcat-5.5.17/logs seems to be helpful.
 
Old 06-15-2006, 12:54 AM   #2
TrevorS
LQ Newbie
 
Registered: May 2006
Location: CT
Distribution: Slackware
Posts: 9

Original Poster
Rep: Reputation: 0
typo

...don't worry, my script really does have the ; instead of the '

if [ -x /etc/rc.d/rc.tomcat ]; then
 
Old 06-15-2006, 01:54 AM   #3
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You should use:
Code:
export JAVA_HOME=/path/to/java
export CATALINA_HOME=/path/to/tomcat
before anthing else in your script, since those env. variables are not defined yet.

Regards
 
Old 06-15-2006, 08:26 AM   #4
TrevorS
LQ Newbie
 
Registered: May 2006
Location: CT
Distribution: Slackware
Posts: 9

Original Poster
Rep: Reputation: 0
fixed!

That did it!

I had the export statements in /etc/profile, but I guess that must be read after /etc/rc.d/rc.M, because moving the export statements to rc.M just prior to calling /etc/rc.d/rc.tomcat did the trick.

Maybe this is basic stuff to you folks, but I don't know how I would hae figured it out as a newbie without you. Thanks!
 
Old 08-04-2006, 12:51 AM   #5
Lee Barker
Member
 
Registered: Jan 2005
Location: London
Distribution: Fedora 6
Posts: 31

Rep: Reputation: 15
Hi,

I have installed Tomcat (following Marty Hall's excellent guide) and everything works fine.

My question is in relation to the startup.sh and catalina.sh files. Why do I need to be root user to start Tomcat? Is there a way to allow the local user to do this?

The only thing I've spotted is that the file tomcat-users.xml is root:root - all else is localuser:users.

So my problem is that I have to su - root each time I need to control the server.

Regards,
Lee.
 
Old 08-04-2006, 01:41 AM   #6
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
I have a tomcat user and tomcat group and I just did chown -R tomcat:tomcat /usr/local/apache-tomcat-5.5.17 - then in my start up script I have:
Code:
/bin/su - tomcat -c /usr/local/bin/start-tomcat.sh
start-tomcat.sh has the environment variables I need and calls the Tomcat startup stuff.

Last edited by gilead; 08-04-2006 at 01:43 AM.
 
Old 08-04-2006, 02:15 AM   #7
Lee Barker
Member
 
Registered: Jan 2005
Location: London
Distribution: Fedora 6
Posts: 31

Rep: Reputation: 15
Thanks for this Steve.

I had created symbolic links to the startup/shutdown scripts and placed them in my home directory.

I also had chgrp/chown the tomcat installation directory in favour of my local user - so I thought that would work.

Does your tomcat user have (root like) higher privileges than a default user?

I must admit that I'm not too familiar with the su options and I guess I can substitute root for your tomcat on my machine (not recommended I know).

Regards,
Lee.
 
Old 08-04-2006, 02:56 PM   #8
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
My tomcat user is a regular user, but for other users in the tomcat group I had to run the following so they could write to the Tomcat directories:
Code:
find /usr/local/apache-tomcat-5.5.17 -type d -exec chmod -c g+ws {} \;
That gave write permissions to the tomcat group to all Tomcat directories as well as making sure the group ownership of files stays at tomcat. My install is for dev/testing so I let the users write to config files, libs, etc. as well as the webapps directory. Nobody but the administrator has rights to the acceptance test and production boxes...
 
Old 09-19-2006, 10:24 PM   #9
wanna13e
Member
 
Registered: Apr 2006
Posts: 45

Rep: Reputation: 15
tomcat startup script

Hi all,

I got which i wrote for my tomcat version 5.0.27 using jsdk 1.4.2 to startup in /etc/init.d but i have some problem with it. Is there any kind soul who can me here. thanks amillion in advance.

Code:
#!/bin/bash
 #
 # Source function library.
. /etc/rc.d/init.d/functions

export JAVA_HOME=/opt/j2sdk
export CLASSPATH=.:/opt/j2sdk/lib/tools.jar:/opt/j2sdk/lib/rt.jar
export PATH=/opt/j2sdk/bin:/j2sdk/bin:$PATH

RETVAL=$?

JAVA_OPTS="-Xincgc -Xms64m -Xmx512m"
SITE_ROOT="/opt/tomcat"
SITES='ls ${SITE_ROOT}

  case "$1" in
    start)
	for x in ${SITES}  
	  do
	    CATALINA_BASE="${SITE_ROOT}/${x}/tomcat"
		if [ -f $CATALINA_BASE/bin/startup.sh];
		  then
			echo "Starting Server: ${x}"
			JAVA_OPTS="${JAVA_OPTS}"
			$CATALINA_BASE/bin/startup.sh
		fi
		done
		;;
		stop)
		  for x in ${SITES}  
		  do
		    CATALINA_BASE="${SITE_ROOT}/${x}/tomcat"
			if [ -f $CATALINA_BASE/bin/shutdown.sh];
			  then
				echo "Shutting down Server: ${x}"
				$CATALINA_BASE/bin/shutdown.sh
			fi
		  done
		  ;;
		  *)
		  echo $"Usage: $0 {start|stop}"
		  exit 1
		  ;;
		  esac
		  exit $RETVAL
 
  


Reply



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
tomcat startup on boot malbery Linux - Software 3 01-27-2005 04:10 PM
startup Tomcat 5.5.4 in Fedora 2 treotan Linux - Newbie 1 12-03-2004 09:46 PM
How to set up tomcat 5 to boot at startup ? jorgepinho Linux - Newbie 1 11-15-2004 07:13 AM
TOMCAT init script not working on startup -- tomcat 4.x / Mandrake Linux 8.0 jmartinph Mandriva 0 03-08-2004 01:31 AM
Tomcat Startup (? is appendage to previous post) ChangeOfPace Linux - Software 7 05-01-2003 06:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:00 PM.

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
Open Source Consulting | Domain Registration