Okay, so I've been working for a while on this, and have been searching, but so far I have not found any answers that actually answer what I want to know. I'm a little bit at the end of my rope with this one, but I'm hoping I can figure this out sometime soon.
So I have Apache 2 installed and serving up standard webpages, but I also have that linked to a Tomcat instance for one of my domains currently supported. However, I want to add another domain to the server via Apache that points to a separate code base from the one I already have. I have been coming at this from several different angles, and I have determined that I just don't know enough about setting up these servers to really do what I want to do.
Little information on my server: Currently running a single Tomcat5.5 instance with Apache 2, using mod_jk to connect them together.
I have a worker in workers.properties that points it's "host" field to "localhost" with the correct port my Tomcat instance, so that all works.
In my Tomcat server.xml file, I have a host defined as "localhost" that points at my webapp that I am currently serving up, with that host set as the defaultHost as well.
One thought I had was that I could add a new worker with a different host than "localhost" (i.e. host2) and then define a new host in my server.xml file called "host2" to match it, but after reading around some on the internet, It seems the "host" of the worker must point to a server, and not a hostname in the Tomcat instance, is this correct?
Again, a simple rundown of what I want: Setup in apache/tomcat combo such that www.domain1.com points at "webapp1" and www.domain2.com points at "webapp2".
First, setup mod_jk workers for both webapps. Below a sample workers.properties
:
workers.tomcat_home=/usr/local/tomcat/apache-tomcat-6.0.20 workers.java_home=/usr/lib/jvm/java-6-sun ps=/ worker.list=worker1,worker2 worker.worker1.type=ajp13 worker.worker1.host=www.domain1.com worker.worker1.port=8009 worker.worker2.type=ajp13 worker.worker2.host=www.domain2.com worker.worker2.port=8009
Then, set up virtual hosts on apache:
<VirtualHost *:80>
ServerName www.domain1.com
JkMount /* worker1
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.com
JkMount /* worker2
</VirtualHost>
Make sure the server.xml
contains an uncommented AJP Connector for port 8009 (matching the workers port). Like this :
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
Finally, configure the tomcat hosts. Something like this:
<Host name="www.domain1.com"
appBase="/path/to/domain1"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false">
<Host name="www.domain2.com"
appBase="/path/to/domain2"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false">
You might need to make some adaptation but it should be close to the final result.