André Warnier wrote:
Kaushal Shriyan wrote:
Hi

I am not able to start tomcat as tomcat user on ubutu 8.04 Linux,
Below is my start/stop script
Any ideas as what is going wrong ?

I think the way you are using the "su" command is wrong.
Try :
su - (userid) -c "command + params"

You also probably want to re-direct the output of "command" to /dev/null etc..

Using another of the scripts existing in /etc/init.d as template, and modifying it, may be a better idea.


As André Warnier suggests, install an init script to handle the startup
and shutdown of Tomcat as a non-privileged user. The following notes
assume a RedHat like Linux distro, such as Fedora or CentOS, but should
be helpful to Ubuntu or Debian users:

1. Configure the environment for the non-privileged user by adding the
   following lines to the end of the file .bash_profile found in the
   user's home directory:

JAVA_HOME=/usr/java/default
CATALINA_HOME=$HOME/tomcat
CATALINA_OPTS="-Xms256M -Xmx1000M -XX:MaxPermSize=128M"
export JAVA_HOME CATALINA_HOME CATALINA_OPTS

   Adjust the heap settings to suit your requirements.

2. As root, install an init script like the following to the /etc/init.d
   directory:

#!/bin/sh

# Start the webapp container

TOMCAT_USER=web

tomcat_start () {
    su -l -c /home/$TOMCAT_USER/tomcat/bin/startup.sh $TOMCAT_USER
}

tomcat_stop () {
    su -l -c /home/$TOMCAT_USER/tomcat/bin/shutdown.sh $TOMCAT_USER
}

case "$1" in
  start)
    tomcat_start
    ;;
  stop)
    tomcat_stop
    ;;
  restart)
    tomcat_stop
    sleep 30
    tomcat_start
    ;;
  *)
    echo "Usage: /etc/init.d/tomcat {start|stop|restart}"
    exit 1
    ;;
esac

exit 0

3. Assuming that the init script has been installed as
   /etc/init.d/tomcat, then run the following commands as root:

# chmod 755 /etc/init.d/tomcat
# ln /etc/init.d/tomcat /etc/rc0.d/K13tomcat
# ln /etc/init.d/tomcat /etc/rc1.d/K13tomcat
# ln /etc/init.d/tomcat /etc/rc2.d/S69tomcat
# ln /etc/init.d/tomcat /etc/rc3.d/S69tomcat
# ln /etc/init.d/tomcat /etc/rc4.d/S69tomcat
# ln /etc/init.d/tomcat /etc/rc5.d/S69tomcat
# ln /etc/init.d/tomcat /etc/rc6.d/K13tomcat

   I find that using hard links rather than sym links makes it easier to
   find all links to an init script using find(1).

4. Tomcat will have to listen on unprivileged ports, such as 8080 and
   8443, so you can either proxy from Apache, or if you have no need to
   run a web server as well as Tomcat then you can use the following
   commands to enable port forwarding:

# /sbin/iptables -A FORWARD -p tcp --destination-port 80 -j ACCEPT
# /sbin/iptables -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port 80 --to-ports 8080
# /sbin/iptables -A FORWARD -p tcp --destination-port 443 -j ACCEPT
# /sbin/iptables -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port 443 --to-ports 8443
# /sbin/service iptables save
# chkconfig iptables on
# service iptables start

Hope this helps,

Chris
--

Chris Wareham
Senior Software Engineer
Visit London Ltd
6th floor,
2 More London Riverside, London SE1 2RR

Tel:  +44 (0)20 7234 5848
Fax: +44 (0)20 7234 5753


www.visitlondon.com





'Visit London Limited' is registered in England under No.761149;
Registered Office: Visit London, 2 More London Riverside, London SE1 2RR.


Visit London is the official visitor organisation for London. Visit London is 
partly funded by Partnership, the Mayor's London Development Agency and London 
Councils.
The information contained in this e-mail is confidential and intended for the 
named recipient(s) only.  If you have received it in error, please notify the 
sender immediately and then delete the message.  If you are not the intended 
recipient, you must not use, disclose, copy or distribute this email. The views 
expressed in this e-mail are those of the individual and not of Visit London. 
We reserve the right to read and monitor any email or attachment entering or 
leaving our systems without prior notice.

 Please don't print this e-mail unless you really need to.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to