You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by johnrock <jo...@yahoo.com> on 2009/05/19 22:00:56 UTC

Deploy Tomcat Standalone - good idea or not?

I am going to be deploying a webapp on CentOS (Spring/Hibernate/Tomcat) that
is JSP based and has hardly any static content..I am planning to start out
with 1 tomcat server and 1 db server.

I think that I do not need an apache front end and can simply run tomcat
standalone. Is this a bad idea? 

The two options I am considering are:
1. Have a firewall redirect traffic directly to my tomcat server on port
8080
or
2. Have a firewall route traffic to an apache instance on port 80 running on
the same machine as tomcat server. Apache would then function merely to
redirect requests to tomcat on port 8080.

Which is a better idea? Or are neither preferred? At this point I do not
want to run a third machine just for apache, but would it cause performance
decrease to run apache on the same machine as my main tomcat server? Is it
neccessary ?


-- 
View this message in context: http://www.nabble.com/Deploy-Tomcat-Standalone---good-idea-or-not--tp23623352p23623352.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by André Warnier <aw...@ice-sa.com>.
johnrock wrote:
> 
> 
> Marcus Better wrote:
>>
>> Tomcat in Debian (and Ubuntu) also runs with jsvc as a non-root user by 
>> default, you can have a look at their startup scripts too.
>>
> 
> Where would I look to find such scripts?
> Thanks
> 
/etc/init.d/tomcatx.y


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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by johnrock <jo...@yahoo.com>.


Marcus Better wrote:
> 
> 
> Tomcat in Debian (and Ubuntu) also runs with jsvc as a non-root user by 
> default, you can have a look at their startup scripts too.
> 

Where would I look to find such scripts?
Thanks

-- 
View this message in context: http://www.nabble.com/Deploy-Tomcat-Standalone---good-idea-or-not--tp23623352p23641030.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by Marcus Better <ma...@better.se>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

johnrock wrote:
> It took me quite a while but I finally got a tomcat startup script working
> using jsvc to start as a tomcat user running on port 80.

> Also, I am posting the startup file I came up with in the hopes that it
> will either serve as a good example for anyone needing this solution 

Tomcat in Debian (and Ubuntu) also runs with jsvc as a non-root user by 
default, you can have a look at their startup scripts too.

Cheers,

Marcus

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkoT8nAACgkQXjXn6TzcAQm3yACfXjLdx7NQPqgjk5EHX7/ZmGfv
eJwAoOzaQzjrYAJyyen1cm4PYFnT1FiV
=NcPr
-----END PGP SIGNATURE-----



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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by George Sexton <ge...@mhsoftware.com>.
This looks pretty much like the one I use on openSuSE. The only 
difference is that I define the variables in a file in /etc/sysconfig.

/etc/sysconfig/tomcat contains.

CATALINA_BASE=
CATALINA_HOME=
TOMCAT_USER=
...

Then, the script sources that file with

. /etc/sysconfig/tomcat

If  I need to change a configuration setting, I'm not modifying a script.

johnrock wrote:
> It took me quite a while but I finally got a tomcat startup script working
> using jsvc to start as a tomcat user running on port 80. 
>
> Are there any drawbacks/cons to this method as opposed to NOT using jsvc and
> instead running tomcat on 8080 and having the firewall redirect to this
> port? Does using jsvc have any hidden ramifications?
>
> Also, I am posting the startup file I came up with in the hopes that it will
> either serve as a good example for anyone needing this solution or else
> someone perhaps can spot any mistakes/problems it may contain.  It is
> working on my system but I am not sure if I am missing anything.
>
> Thanks!
>
>
> #!/bin/sh
> #
> # chkconfig: 2345 85 15
> # description: tomcat starts and stops apache-tomcat services.
> # processname: tomcat
> # pidfile: /var/run/tomcat.pid 
> # Source function library.
> . /etc/init.d/functions
>
> # Read JAVA_HOME, JAVA_JRE, CATALINA_HOME environment variables
> . /etc/profile
>
>
> # Adapt the following lines to your configuration
> DAEMON_HOME=$CATALINA_HOME/bin/jsvc
> TOMCAT_USER=tomcat
>
> # for multi instances adapt those lines.
> TMP_DIR=/var/tmp
> PID_FILE=/var/run/tomcat.pid
> CATALINA_BASE=/usr/share/tomcat
> CATALINA_HOME=/usr/share/tomcat
> CATALINA_OPTS="-jvm server -Xms256M -Xmx256M -XX:MaxPermSize=256M"
> CLASSPATH=\
> $JAVA_HOME/lib/tools.jar:\
> $CATALINA_HOME/bin/commons-daemon.jar:\
> $CATALINA_HOME/bin/bootstrap.jar
>
> RETVAL=0 
>
>
>   start(){
>     #
>     # Start Tomcat
>     #
>     echo -n "Starting tomcat: "
>     chown -R $TOMCAT_USER:$TOMCAT_USER /usr/share/tomcat/*
>     $DAEMON_HOME \
>     -user $TOMCAT_USER \
>     -home $JAVA_HOME \
>     -Dcatalina.home=$CATALINA_HOME \
>     -Dcatalina.base=$CATALINA_BASE \
>     -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
>     -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties \
>     -Djava.io.tmpdir=$TMP_DIR \
>     -Djava.awt.headless=true \
>     -wait 10 \
>     -pidfile $PID_FILE \
>     -outfile /var/log/tomcat/catalina.out \
>     -errfile /var/log/tomcat/catalina.err \
>     $CATALINA_OPTS \
>     -cp $CLASSPATH \
>     org.apache.catalina.startup.Bootstrap
>     #
>     # To get a verbose JVM
>     #-verbose \
>     # To get a debug of jsvc.
>     #-debug \
>   }
>   stop(){
>     #
>     # Stop Tomcat
>     #
>     echo -n "Stopping tomcat: "
>     $DAEMON_HOME \
>     -stop \
>     -pidfile $PID_FILE \
>     org.apache.catalina.startup.Bootstrap
>   }
>
>
> # See how we were called.
> case "$1" in
>       start)
>          if [ -f $PID_FILE ] ; then
>             echo "Apache-Tomcat already running! Try STOP first..."
>          else
>             start
>             fi
>            ;;
>         stop)
>            stop
>            ;;
>         restart)
>           stop
>           sleep 5
>           start
>              ;;
> status)
>     if [[ -f $PID_FILE ]]
>     then
>       echo "found a pidfile so we are probably up and running."
>     else
>       echo "no pidfile so we are probably down."
>     fi
>     exit 1
>     ;;
>
>       *)
>       echo "Usage: $0 {start|stop|restart|status}"
>       exit 1
> esac
>
> exit $RETVAL
>
>   

-- 
George Sexton
MH Software, Inc.
Voice: +1 303 438 9585
URL:   http://www.mhsoftware.com/


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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by johnrock <jo...@yahoo.com>.
It took me quite a while but I finally got a tomcat startup script working
using jsvc to start as a tomcat user running on port 80. 

Are there any drawbacks/cons to this method as opposed to NOT using jsvc and
instead running tomcat on 8080 and having the firewall redirect to this
port? Does using jsvc have any hidden ramifications?

Also, I am posting the startup file I came up with in the hopes that it will
either serve as a good example for anyone needing this solution or else
someone perhaps can spot any mistakes/problems it may contain.  It is
working on my system but I am not sure if I am missing anything.

Thanks!


#!/bin/sh
#
# chkconfig: 2345 85 15
# description: tomcat starts and stops apache-tomcat services.
# processname: tomcat
# pidfile: /var/run/tomcat.pid 
# Source function library.
. /etc/init.d/functions

# Read JAVA_HOME, JAVA_JRE, CATALINA_HOME environment variables
. /etc/profile


# Adapt the following lines to your configuration
DAEMON_HOME=$CATALINA_HOME/bin/jsvc
TOMCAT_USER=tomcat

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/tomcat.pid
CATALINA_BASE=/usr/share/tomcat
CATALINA_HOME=/usr/share/tomcat
CATALINA_OPTS="-jvm server -Xms256M -Xmx256M -XX:MaxPermSize=256M"
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar

RETVAL=0 


  start(){
    #
    # Start Tomcat
    #
    echo -n "Starting tomcat: "
    chown -R $TOMCAT_USER:$TOMCAT_USER /usr/share/tomcat/*
    $DAEMON_HOME \
    -user $TOMCAT_USER \
    -home $JAVA_HOME \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
    -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties \
    -Djava.io.tmpdir=$TMP_DIR \
    -Djava.awt.headless=true \
    -wait 10 \
    -pidfile $PID_FILE \
    -outfile /var/log/tomcat/catalina.out \
    -errfile /var/log/tomcat/catalina.err \
    $CATALINA_OPTS \
    -cp $CLASSPATH \
    org.apache.catalina.startup.Bootstrap
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    #-debug \
  }
  stop(){
    #
    # Stop Tomcat
    #
    echo -n "Stopping tomcat: "
    $DAEMON_HOME \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap
  }


# See how we were called.
case "$1" in
      start)
         if [ -f $PID_FILE ] ; then
            echo "Apache-Tomcat already running! Try STOP first..."
         else
            start
            fi
           ;;
        stop)
           stop
           ;;
        restart)
          stop
          sleep 5
          start
             ;;
status)
    if [[ -f $PID_FILE ]]
    then
      echo "found a pidfile so we are probably up and running."
    else
      echo "no pidfile so we are probably down."
    fi
    exit 1
    ;;

      *)
      echo "Usage: $0 {start|stop|restart|status}"
      exit 1
esac

exit $RETVAL

-- 
View this message in context: http://www.nabble.com/Deploy-Tomcat-Standalone---good-idea-or-not--tp23623352p23632388.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by Hassan Schroeder <ha...@gmail.com>.
On Tue, May 19, 2009 at 2:12 PM, johnrock <jo...@yahoo.com> wrote:

> Thank you for your comments. I would love to simply run tomcat on port 80 as
> tomcat user. I have not yet discovered how to do this and have been running
> as 'tomcat' user on port 8080. I had seen some posts mentioning JSVC but I
> remain unclear about what this is for.

<http://tomcat.apache.org/tomcat-6.0-doc/setup.html> should help :-)

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by johnrock <jo...@yahoo.com>.


George Sexton wrote:
> 
> Use JSVC to run tomcat on Port 80 without having it run as root. Unpack 
> the source for jsvc from the bin directory and compile it.
> 

Thank you for your comments. I would love to simply run tomcat on port 80 as
tomcat user. I have not yet discovered how to do this and have been running
as 'tomcat' user on port 8080. I had seen some posts mentioning JSVC but I
remain unclear about what this is for.  I actually already compiled that
package on my test server but was not sure what I need to do with it.  I
will research that some more but if you can offer any more explanation on
how to do this I would greatly appreciate it as I have had a hard time
figuring this out. 

I already have my tomcat startup script in /etc/init.d working great running
as tomcat user ...is there a simple change I need to make there to run on
port 80?

Thank you so much

-- 
View this message in context: http://www.nabble.com/Deploy-Tomcat-Standalone---good-idea-or-not--tp23623352p23624163.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by George Sexton <ge...@mhsoftware.com>.

johnrock wrote:
> I am going to be deploying a webapp on CentOS (Spring/Hibernate/Tomcat) that
> is JSP based and has hardly any static content..I am planning to start out
> with 1 tomcat server and 1 db server.
>
> I think that I do not need an apache front end and can simply run tomcat
> standalone. Is this a bad idea? 
>   
I think it's a good idea.

> The two options I am considering are:
> 1. Have a firewall redirect traffic directly to my tomcat server on port
> 8080
> or
> 2. Have a firewall route traffic to an apache instance on port 80 running on
> the same machine as tomcat server. Apache would then function merely to
> redirect requests to tomcat on port 8080.
>   
Use JSVC to run tomcat on Port 80 without having it run as root. Unpack 
the source for jsvc from the bin directory and compile it.

> Which is a better idea? Or are neither preferred? At this point I do not
> want to run a third machine just for apache, but would it cause performance
> decrease to run apache on the same machine as my main tomcat server? Is it
> neccessary ?
>
>
>   

-- 
George Sexton
MH Software, Inc.
Voice: +1 303 438 9585
URL:   http://www.mhsoftware.com/


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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

On 5/19/2009 4:37 PM, André Warnier wrote:
> Well, maybe Chris could add one column to his tests, showing Apache +
> mod_jk proxying the requests to Tomcat ?

Yup, I'll be doing that, too. I think I'll add mod_proxy_ajp and
mod_proxy_http to the list as well. Why not tie up my server for the
next 12 nights? :)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkoTNKAACgkQ9CaO5/Lv0PCXpgCfW1npDaocHA9M5uRcLN63Ya8y
JTcAnRndBYtgfYYa6f6jyfY4ShxN1frp
=jnJp
-----END PGP SIGNATURE-----

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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by André Warnier <aw...@ice-sa.com>.
johnrock wrote:
> I am going to be deploying a webapp on CentOS (Spring/Hibernate/Tomcat) that
> is JSP based and has hardly any static content..I am planning to start out
> with 1 tomcat server and 1 db server.
> 
> I think that I do not need an apache front end and can simply run tomcat
> standalone. Is this a bad idea? 
> 
> The two options I am considering are:
> 1. Have a firewall redirect traffic directly to my tomcat server on port
> 8080
> or
> 2. Have a firewall route traffic to an apache instance on port 80 running on
> the same machine as tomcat server. Apache would then function merely to
> redirect requests to tomcat on port 8080.
> 
> Which is a better idea? Or are neither preferred? At this point I do not
> want to run a third machine just for apache, but would it cause performance
> decrease to run apache on the same machine as my main tomcat server? Is it
> neccessary ?
> 
> 
Well, maybe Chris could add one column to his tests, showing Apache + 
mod_jk proxying the requests to Tomcat ?
(reference to another thread, "Apache httpd vs Tomcat static content 
performance [some results]"
Then we'd see how much overhead Apache + mod_jk add to the mix.

In any case, considering the setup you explain above, there does not 
seem to be any point to have a front-end Apache, at the contrary it can 
only add overhead and complexity.
But make sure to read this other thread if you have static content, at 
least to choose the correct Tomcat Connector configuration.



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


Re: Deploy Tomcat Standalone - good idea or not?

Posted by David kerber <dc...@verizon.net>.
johnrock wrote:
> I am going to be deploying a webapp on CentOS (Spring/Hibernate/Tomcat) that
> is JSP based and has hardly any static content..I am planning to start out
> with 1 tomcat server and 1 db server.
>
> I think that I do not need an apache front end and can simply run tomcat
> standalone. Is this a bad idea? 
>   
No, it's a good idea.
> The two options I am considering are:
> 1. Have a firewall redirect traffic directly to my tomcat server on port
> 8080
> or
> 2. Have a firewall route traffic to an apache instance on port 80 running on
> the same machine as tomcat server. Apache would then function merely to
> redirect requests to tomcat on port 8080.
>
> Which is a better idea? Or are neither preferred? At this point I do not
> want to run a third machine just for apache, but would it cause performance
> decrease to run apache on the same machine as my main tomcat server? Is it
> neccessary ?
>   
You'd get some performance drop, but probably not a lot.  Why not just 
put tomcat listening on port 80?

D



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