You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Robert Riley <ri...@shands.ufl.edu> on 2003/01/09 22:29:37 UTC

JK2 + multiple JVM + multiple virtual hosts

On one Apache server I am running multiple tomcat installations, each one 
serves a seperate virtual host. This is considered an advanced use case and is 
not very well documented for JK2, so I thought I would pass this along.

I run Apache 2.0.43, TC 4.1.18, and mod_jk2 out of process over 
regular sockets.

This config would be good for the ISP model - each host gets private JVM.

Or in my case, I provide seperate development, test, and production 
tomcat servers. This allows me to migrate code changes.

Either case, contexts only load for specific hosts and a JVM can go up/down 
without effecting other hosts.

Neither tomcat installation uses the value of the environment variable 
CATALINA_HOME, rather I explicitly set in shell scripts for each tomcat. 
Otherwise they both try to start the same server. I found this out because 
I still had tomcat 4.0.6 on my box and when I ran my 4.1.8 startup script, that 
it launched 4.0.6 using default env! My second tomcat 4.1.8 got a BindException 
of course when it tried to also start 4.0.6 using default env.
Lesson learned - So now each tomcat gets hard coded env CATALINA_HOME.

Here are my config files for regular sockets:

Note:

/jkstatus loads only into the default server
/someApp loads only into fred.com
/anotherApp loads only into wilma.com

Of course, fred and wilma server.xml get diferrent shutdown ports also.
----------------------------------------------------------
workers2.properties
----------------------------------------------------------
# TYPE:NAME.PROPERTY=VALUE 
#        OR
# [TYPE:NAME]
# PROPERTY=VALUE
[logger]
level=DEBUG

[config:]
file=${serverRoot}/conf/workers2.properties
debug=2
debugEnv=0

[uriMap:]
info=Maps the requests. Options: debug
debug=4

#the shared memory depository
[shm:]
info=Scoreboard.
file=${serverRoot}/logs/jk2.shm
size=1000000
debug=0
disabled=0

[workerEnv]
info=global options
timing=1
debug=0

[lb:lb]
info=the default load balancer
debug=0

[channel.socket:fred]
info=ajp13 forwarding to fred.com JVM
debug=0
tomcatId=fred
port=8019
host=localhost

[channel.socket:wilma]
info=ajp13 forwarding to wilma.com JVM
debug=0
tomcatId=wilma
port=9019
host=localhost

[ajp13:fred]
channel=channel.socket:fred
tomcatId=fred

[ajp13:wilma]
channel=channel.socket:wilma
tomcatId=wilma

[status:]
info=status worker

# default host mapping
[uri:/jkstatus/*]
group=status

# fred.com context mappping

[uri:fred.com/someApp]
group=ajp13:fred
context=/someApp

# fred.com uri mapping

[uri:fred.com/someApp/*]
group=ajp13:fred

# wilma.com context mappping

[uri:wilma.com/anotherApp]
group=ajp13:wilma
context=/anotherApp

# wilma.com uri mappping

[uri:wilma.com/anotherApp/*]
group=ajp13:wilma

------------------------------------------------
jk2.properties - fred installation of tomcat
-----------------------------------------------
handler.list=channelSocket,request
channelSocket.port=8019
------------------------------------------------
jk2.properties - wilma installation of tomcat
-----------------------------------------------
handler.list=channelSocket,request
channelSocket.port=9019
---------------------------------------------------
server.xml   - fred instance of tomcat
--------------------------------------------------
<Server port="8005" shutdown="SHUTDOWN" debug="4">
  <Service name="Tomcat-Apache-fred">

    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
            port="8019" minProcessors="5" maxProcessors="75"
            enableLookups="true" appBase="webapps" 
            acceptCount="10" debug="4"      
            protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

    <Engine className="org.apache.catalina.core.StandardEngine"
            name="Apache" debug="4" defaultHost="fred.com">

      <Host name="fred.com" debug="4" 
              appBase="webapps" unpackWARs="true">

        <Logger className="org.apache.catalina.logger.FileLogger"
                prefix="fred-apache_log." suffix=".txt" timestamp="true"/>

        <Context path="" docBase="ROOT" debug="4"/>

        <Realm className="org.apache.catalina.realm.MemoryRealm" />
      </Host>
    </Engine>
  </Service>
</Server>
---------------------------------------------------
server.xml   - wilma instance of tomcat
--------------------------------------------------
<Server port="9005" shutdown="SHUTDOWN" debug="4">
  <Service name="Tomcat-Apache-wilma">

    <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
            port="9019" minProcessors="5" maxProcessors="75"
            enableLookups="true" appBase="webapps" 
            acceptCount="10" debug="4"      
            protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

    <Engine className="org.apache.catalina.core.StandardEngine"
            name="Apache" debug="4" defaultHost="wilma.com">

      <Host name="wilma.com" debug="4" 
              appBase="webapps" unpackWARs="true">

        <Logger className="org.apache.catalina.logger.FileLogger"
                prefix="wilma-apache_log." suffix=".txt" timestamp="true"/>

        <Context path="" docBase="ROOT" debug="4"/>

        <Realm className="org.apache.catalina.realm.MemoryRealm" />
      </Host>
    </Engine>
  </Service>
</Server>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>