The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tomcat Question

Discussion in 'General Discussion' started by lamp, Nov 16, 2007.

  1. lamp

    lamp Well-Known Member

    Joined:
    Dec 22, 2003
    Messages:
    111
    Likes Received:
    0
    Trophy Points:
    16
    Does cpanel 11 install tomcat so that each virtual host has it's own instance?
     
  2. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    No.

    There is one main Tomcat process and several children.
     
  3. lamp

    lamp Well-Known Member

    Joined:
    Dec 22, 2003
    Messages:
    111
    Likes Received:
    0
    Trophy Points:
    16
    Actually, I was able to get 5 instances of tomcat running on cpanel 11... and it really works like a charm.

    In Summary:
    ---------------
    I have the main tomcat installed (CATALINA_HOME) in /usr/local/jakarta/tomcat (symlinked to whatever version I want) and 5 instances with their own webapps,logs,conf, and temp (CATALINA_BASE). This is great because it means that each instance has their own manager, users, and are completely independent of one another. Also, if I upgrade tomcat, then there is no need to upgrade five of them... just CATALINA_HOME and all the others are automatically upgraded (saves space too).

    Another advantage is that I can also start, stop, restart each individual instance without bothering other clients on tomcat.

    Yes, to get things setup properly does take a little more work because I have to create distinct ajp13 worker for each instance... but the advantages are huge.

    Thanks.
     
  4. lamp

    lamp Well-Known Member

    Joined:
    Dec 22, 2003
    Messages:
    111
    Likes Received:
    0
    Trophy Points:
    16
    If anyone is looking to have 1 main tomcat and many instances running, let me know and I can post a how-to.

    It's fairly straightforward.

    Lamp.
     
  5. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Well sure, if you do the other 4 installs manually. But that wasn't the question. You can also run multiple Tomcat instances from the same CATALINA_HOME locaiton using jsvc. Check out http://miti.sourceforge.net/ for example.
     
  6. lamp

    lamp Well-Known Member

    Joined:
    Dec 22, 2003
    Messages:
    111
    Likes Received:
    0
    Trophy Points:
    16
    ... MITI package looks good.
     
    #6 lamp, Nov 16, 2007
    Last edited: Nov 16, 2007
  7. lamp

    lamp Well-Known Member

    Joined:
    Dec 22, 2003
    Messages:
    111
    Likes Received:
    0
    Trophy Points:
    16
    You still have to configure the AJP connectors manually... miti just reduces the manual work.
     
  8. rgrocha

    rgrocha Member

    Joined:
    Aug 9, 2007
    Messages:
    7
    Likes Received:
    1
    Trophy Points:
    3
    I'm interested!
     
  9. lamp

    lamp Well-Known Member

    Joined:
    Dec 22, 2003
    Messages:
    111
    Likes Received:
    0
    Trophy Points:
    16
    HOWTO: Install multiple tomcat instances with cPanel x.xx

    Here's why you would want to do this:
    ==============================
    1) Install tomcat in 1 location and have x number of instances running on a per client basis
    2) Upgrade tomcat and have it propagate to all clients
    3) Limit the resources each tomcat instance uses
    4) Tomcat runs as the individual user rather than "root" or "tomcat"
    5) Each user has its own manager; hence, no security risk to others
    6) Start/Stop/Restart tomcat instances without affecting other clients who also have a tomcat instance

    Assumptions:
    ============
    1. Tomcat is installed in: /usr/local/tomcat (TOMCAT_HOME)
    2. Instances are installed in: /usr/local/tomcat/instances
    3. Java is installed somewhere on your machine

    Step 1 - Create a Tomcat Instance
    =================================
    - Create a directory in /usr/local/tomcat/instances/user1 (CATALINA_BASE)
    - Create a set of directories (conf,temp,logs,webapps) in $CATALINA_BASE
    - Copy web.xml,server.xml,tomcat-users.xml from $TOMCAT_HOME/conf to $CATALINA_BASE/conf
    - Create a bash script called user1startstop.sh as follows and make it executable
    Step 2 - Configure the Tomcat Instance
    ======================================
    - edit $TOMCAT_BASE/conf/server.xml:

    Replace: ... port=8005 with port 8101 ... This is shutdown port
    Replace: ... port=8080 with port 8201 ... This is http port
    Replace: ... port=8009 with port 8301 ... This is the AJP port

    - edit $TOMCAT_HOME/conf/workers.properties

    Add: user1 to worker.list=ajp12,ajp13...
    Add:
    worker.user1.host=localhost
    worker.user1.port=8301
    worker.user1.lbfactor=1
    worker.user1.type=ajp13
    Under:
    DEFAULT ajp13 WORKER DEFINITION

    Step 3 - Modify Main Tomcat (One-Time)
    ======================================
    Edit $TOMCAT_HOME/bin/Tomcat5.sh

    Add:
    Modify start case with the following:
    Modify end case with the following:
    Step 3 - Configure Apache
    =========================

    - Edit httpd.conf
    Add the following code under the VirtualHost definition of the user in question:
    <IfModule mod_jk.c>
    JkMount /*.jsp user1
    JkMount /webapps/* user1
    JkMount /servlets/* user1
    JkMount /servlet/* user1
    </IfModule>


    Step 4 - Restart Apache

    Step 5 - run $TOMCAT_INSTANCE/user1startstop.sh start

    That's it.
     
  10. wisperz

    wisperz Registered

    Joined:
    Oct 26, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Problem Configuring Multi Instance Tomcat

    Hi,

    Before Setting Multi Instance Tomcat:

    I already install tomcat using cpanel /easyapache installer, I can assign user with [Install Servlet] link in WHM and it works already [can display the jsp test page].
    But according to one of my user it is only JSP and not servlet since it can not load .do file.

    I hope after Setting Multi Install Tomcat, I can provide servlet ready function to my user but still fail.

    I have follow all your configuration detail but still can't running usr1startstop.sh.

    The warning is: jsvc Invalid name - 'collabs

    -Dcatalina-home : file / directory not found
    -Dcatalina-home : file / directory not found

    Notes:
    I change all user1 to collabs [collabs is one of my user's username]
    I use jakarta/tomcat folder instead of tomcat only.

    Please help.
    Thanks.
     
  11. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    What is a .do file?
     
  12. appservermgr

    appservermgr Member

    Joined:
    Feb 16, 2007
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    .do is the commonly used path extension of Struts.
    Struts is the most popular JAVA Framework in use:
    http://struts.apache.org
     
  13. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Thanks for the info. I've never used struts.
     
  14. lamp

    lamp Well-Known Member

    Joined:
    Dec 22, 2003
    Messages:
    111
    Likes Received:
    0
    Trophy Points:
    16
    Add /*.do like this:

    <IfModule mod_jk.c>
    JkMount /*.jsp user1
    JkMount /webapps/* user1
    JkMount /servlets/* user1
    JkMount /servlet/* user1
    JkMount /*.do user1
    </IfModule>
     
  15. Vinayak

    Vinayak Well-Known Member

    Joined:
    Jun 27, 2003
    Messages:
    267
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Bharat
    cPanel Access Level:
    Root Administrator
    It seems there is a bug somewhere or may be some misconfiguration, this is what I am getting (TomCat installed by WHM):

    whereas the index.jsp is working fine at http://www.sakariya.com

    The developer says, it is not compiling JSP pages.

    Any idea where it is going wrong?
     
  16. Vinayak

    Vinayak Well-Known Member

    Joined:
    Jun 27, 2003
    Messages:
    267
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Bharat
    cPanel Access Level:
    Root Administrator
    Ok I was able to fix the issue by tweaking server.xml <Host></Host> entries.

    But when installed servlets on another domain through WHM it added its default <Host></Host> entries for the new domain and overwrite the tweaked entries of old domain by its default one.

    Is this a bug or is it using some template somewhere?

    If it is using a template from somewhere, where is it located so we can fix the template, any idea?

    BTW my tweaked entries are:

    Above entry is working fine for me, application get deployed automatically without restarting TomCat, any changes made to application are also accepted without restart.

    But do you people think every thing is fine in above entry, is there a better and more efficient way?

    Any tips to optimise TomCat to consume less resources and for better performance?
     
  17. rdhallman

    rdhallman Registered

    Joined:
    Nov 30, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Thanks Lamp for the HowTo about tomcat multi-instance on cpanel.

    I'm trying to put it to good use, but having some issues:

    I have a virgin installation of CPanel and tomcat. First time it has been used. Tomcat5.5.28 is installed at /usr/local/jakarta/tomcat/

    Problem is, Tomcat5.sh is not included in the bin directory. Has the latest versions of cpanel put this file elsewhere or something?



    Hmm... But cpanel will overwrite your edits directly to httpd.conf. As I understand it, to distill a manual modification to httpd.conf you must run /usr/local/cpanel/bin/apache_conf_distiller --update after you have saved the config file

    Did you not (over time) have any such problems with cpanel overwriting your httpd.conf edits?
     
    #17 rdhallman, Nov 30, 2009
    Last edited: Nov 30, 2009
Loading...

Share This Page