Forum Moderators: phranque
I have to use a servlet for some application, but my site is write with PHP (and I need it).
I read that it is possible to install Tomcat as a module to Apache and I am interrested by your experience in this area (installation difficulties, stability...).
thanks you for yours comments,
Jean-Marie
There are a few steps - some of this might be a bit obvious but don't know what you know.
1- Get Tomcat working as a standalone server (you would use URLs a bit like [blabla.com:8080)....]
2- Get Tomcat to serve servlets without any involvement from apache (use urls like [blabla.com:8080...]
3- Turn on mod_jk in Apache (in your httpd.conf)
LoadModule jk_module /usr/libexec/httpd/mod_jk.so
and
AddModule mod_jk.c
Then add this:
<IfModule mod_jk.c>
JkWorkersFile /Library/Tomcat/conf/workers.properties
JkLogFile /Library/Tomcat/logs/jklog.log
JkLogLevel error
</IfModule>
4- Make a workers.properties file and put it where you defined your JkWorkersFile just now. The simplest version is this:
#
# workers.tomcat_home should point to the location where you
# installed tomcat. This is where you have your conf, webapps and lib
# directories.
#
workers.tomcat_home=/Library/Tomcat/
#
# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
#
workers.java_home=/usr/bin/
# Define what the path separator is = / on unix \ on
# windows
ps=/
# The workers that your plugins should create and work with
#
worker.list=ajp13
# Defining a worker named ajp13 and of type ajp13
# The port number will be as you find in your Tomcat server.xml file.
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
5- Map urls to Jk, so as to define what patterns get passed on. Under your virtual server, put lines like this:
JkMount /sv ajp13
JkMount /sv/* ajp13
JkMount /administration/sv/* ajp13
That means that [blabla...] will go to Tomcat, but [blabla...] doesn't.
6- Give it a try. If it's not working, go back to JkLogLevel and make it debug, restart and tail the JkLogFile for clues.
7- (Once it is working, turn off the port 8080 or whatever part of Tomcat, so that everything must go through Apache and you can't hit a url like [blabla:8080...] and get to servlets without passing through apache.)
Sorry its a bit brief. For each step you might need to do some searching on Tomcat, Apache or both sites but those are the steps.