tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex <a...@squigly.net>
Subject virtual hosts howto! (jk2/apache2.0.50||iis5.0/tomcat5.0.25)
Date Fri, 17 Sep 2004 07:55:10 GMT

For a while now, i've been making posts, which for the most part have gone
unanswered.  Mostly I believe it's because people that do know the answer
aren't on the list...Anyways, I threw together a few docs about how i
managed to finally get everythign working fine with the above apps.

A lot of this was taken from documentation i've found scattered around the
internet and stuffed into README's...

1.  With apache: (assumes you have apache working)

Obtain the Tomcat JK2 connectors source code.  http://jakarta.apache.org/
jakarta-tomcat-connectors-jk2-2.0.4-src was used in this instance.
Unpack the distribution and enter the directory.

        cd jk/native2

Compile the JK2 adapter:
        - the options used:
                #! /bin/sh
                #
                # Created by configure
                "./configure " \
                "--with-jni " \
                "--with-apxs2=/opt/apache-2.0.50/bin/apxs " \
                "--with-apache2=/usr/local/src/httpd-2.0.50 " \
                "--with-java-home=/usr/local/jdk " \
                "$@"

        - make.  once it's finished compiling go find the module: cd ../build/jk2/apache2

Now, we want to take the module we've compiled against the apache2 apxs
and do something with it.

        - /opt/apache-2.0.50/bin/apxs -n jk2 -i mod_jk2.so

Add the following to the apache httpd.conf:

                LoadModule jk2_module modules/mod_jk2.so

Create a workers2.properties in conf (where httpd.conf is localised).
The one located below was developed and is used to support clustered
tomcat application servers.

[shm]
file=/tmp/shm.file
size=1048576

[lb:lb]
info=Tomcat load balance

[channel.socket:server1]
port=8009
host=10.1.1.1
type=ajp13
group=lb

[channel.socket:server2]
port=8009
host=10.1.1.2
type=ajp13
group=lb

[uri:www.virtualhost1.com/*.jsp]
worker=lb:lb

[uri:www.virtualhost1.com/*.do]
worker=lb:lb

[uri:www.virtualhost2.com/*.jsp]
worker=lb:lb

[uri:www.virtualhost2.com/*.do]
worker=lb:lb

2.  With IIS5.0

Obtain the binary release for the JK2 isapi dll from http://jakarta.apache.org/

Create a registry file and insert the following information into it:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\2.0]
"workersFile"="C:\\Apache\\Tomcat5\\conf\\workers2.properties"
"extensionUri"="/jakarta/isapi_redirector2.dll"
"logLevel"="debug"
"serverRoot"="C:\\Apache\\Tomcat5\\"

Create the folders which have been defined above in the registry file.

Double click the registry file to import it into the registry.

Create the virtual hosts in iis5.0 according to the iis documentation.
Register a new isapi dll with the virtual host and ensure that a virtual
directory within the virtual host exists called: jakarta which points at
the directory where the isapi_dll is stored.  Restart IIS and you should
see in the properties, under isapi, the dll is now green.

Create a workers2.properties in conf in the directory that workersFile is
defined in the registry file.  The one located below was developed and is
used to support clustered tomcat application servers.

(Use the one in the apache example.  The only difference is that the
shm.file will move to somewhere other then /tmp)

3.  Setting up tomcat

By default, in server.xml for tomcat, you'll have the following host set up:

<Host appBase="webapps" name="localhost" unpackWARs="true" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
  <Valve className="org.apache.catalina.authenticator.SingleSignOn"/>
  <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
</Host>

To get virtual hosts working so that the jk2 adapters work, create
another. (I created a new dir $CATALINA_HOME$/virtual-hosts)

<Host appBase="virtual-hosts/www.virtualhost1.com"
	name="www.virtualhost1.com" unpackWARs="true"
	autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
  <Valve className="org.apache.catalina.authenticator.SingleSignOn"/>
  <Logger className="org.apache.catalina.logger.FileLogger"
	prefix="www.virtualhost1.com_log." suffix=".txt" timestamp="true"/>
</Host>

<Host appBase="virtual-hosts/www.virtualhost2.com"
	name="www.virtualhost2.com" unpackWARs="true"
	autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
  <Valve className="org.apache.catalina.authenticator.SingleSignOn"/>
  <Logger className="org.apache.catalina.logger.FileLogger"
	prefix="www.virtualhost2.com_log." suffix=".txt" timestamp="true"/>
</Host>

Now all of it should work.  Apps deployed to virtualhost1 will not be seen
by virtualhost2

Hope this helps a few people save a few hours of searching and mucking
about...




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


Mime
View raw message