LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 12-20-2009, 04:08 PM   #1
dreamality
LQ Newbie
 
Registered: Dec 2009
Posts: 1

Rep: Reputation: 0
How to setup Tomcat to run as user and daemon in Lunix/Redhat ?


I have the following:
* A redhat box running Fedora release 7 (Moonshine)
* Tomcat apache-tomcat-6.0.18 distribution

Currently, Apache is setup to work with Tomcat using the AJP connector, that works fine.

When I boot the box I su root and then I run the script startup.sh which is on the bin directory of tomcat, that starts tomcat without a problem. I can close my root session, my ssh and tomcat keeps running.

The problem is that running as root is a huge security problem. I run multiple virtual hosts in tomcat and although all sites are developed by me, I want to prevent any webapp from causing any harm such as:

* System.exit() which will shutdown Tomcat
* writing to secure directories
* practically control the box!

I need to be able to run tomcat as user not as root and also as a daemon on start up so that I don't need to manually start it.

Any help on the subject will be much appreciated!
 
Old 12-21-2009, 07:55 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Here's one I sanitized earlier, it's pretty basic:

Code:
#!/bin/bash
# description: tomcat init script

RETVAL=0
prog1="tomcat"


start() {
        echo -n $"Starting $prog1: "
        su - tomcat -c "cd /app/tomcat5; ./bin/tcctl.sh start 1"
        RETVAL=$?
        echo
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog1: "
        su - tomcat -c "cd /app/tomcat5; ./bin/tcctl.sh stop 1"
        RETVAL=$?
        echo
        return $RETVAL
}


case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  *)
        echo $"Usage: $0 {start|stop}"
        RETVAL=1
esac
... you get the idea

cheers
 
  


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
How to run daemon process being a normal user [not root user]. narendra1310 Linux - Software 1 10-26-2009 09:48 AM
run daemon as user in mandriva 2006? smiler Mandriva 2 03-14-2006 02:06 AM
How to run startup script/daemon as a user other than root? Akhran Debian 2 02-04-2006 01:20 AM
non-root user unable to run tomcat with usb ports mar38 Linux - Software 0 07-21-2004 02:45 AM
user under which apache tomcat run?? Sridhar Guntur Linux - Security 2 08-28-2003 01:06 PM

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

All times are GMT -5. The time now is 04:52 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
Open Source Consulting | Domain Registration