Quick and Dirty, no thinking version here for those who just want to blast it in.
Note: In an effort to reduce convoluted path names in windows try to choose install directories with short names. Also try not to use spaces in the names, Apache and Tomcat and as far as I know all XML files have problems with it and require you to double quote any path name that includes spaces. Save yourself some headaches and just don’t do it.
Note: Careful planning of installation paths can be a good thing. For instance, combining the DocumentRoot of Apache and the webapp directory of Tomcat can lead to automatic application configuration by Tomcat 4.1.10. I haven’t tried it so it’s just a theory mind you, but it sounds good.
(Make sure you get the windows version, of the latest available, but it should work with any 1.4 version)
No need to install src or demos. You will need to check the “JRE for windows drive only” option unless you want to edit the registry and point the key to the jvm.dll in the JDSK. It’s easier to go ahead and take the default though. No matter where you choose to install the JSDK sun’s install still puts the JRE in the “Program Files” directory. I chose an install path of c:\java. So try to keep it simple.
Set system environment variables for Java home.
Add JAVA_HOME and JAVA_HOME\bin directory to the system PATH variable in my case it is
Get the latest available. Download the correct program for your system. The one ending in .exe is for people who do not have the msi installer yet, most do, so the smaller .msi package should work for most people. Make a nice short path without any blank spaces for the installation. Mine is C:\Apache2
During installation set domain and ServerName to Your Server Name or just localhost if you’re just testing. It will only be accessible from the local machine.
Get the latest release version. At the time of this writing it was 4.1.12. You must get the LE version of Tomcat. JDK 1.4.x has an XML parser installed so the LE version of Tomcat was made for this reason. During installation you don’t have to select the check box for NT service. Again make sure to choose a nice short install path without any blanks in the names. Mine is C:\Tomcat
Set system environment variables for Tomcat home. It might also be a good idea to add a Catalina home too.
Get the latest version of mod_jk2.dll and save it to the APACHE_HOME/modules directory. The new modules are version named to ID them to different Apache versions. You can rename them to mod_jk2.dll or change the LoadModule statement to match the version you are installing. In either case the module name and the LoadModule statement have to match. I just renamed the module to be mod_jk2.dll.
In your httpd.conf file add this LoadModule statement to the beginning of the LoadModule section.
LoadModule jk2_module modules/mod_jk2.dll
In your APACHE_HOME/logs directory you will need to create three empty files.
Cut and paste the following workers2.properties file into the APACHE_HOME/conf directory. There’s lots of extra stuff to experiment with here later. (Edit paths to suit)
info=Maps the requests. Options: debug
# Alternate file logger
info=Scoreboard. Required for reconfiguration and status with multiprocess servers
info=Global server options
# Default Native Logger (apache2 or win32 )
# can be overriden to a file logger, useful
# when tracing win32 related issues
info=Default load balancer.
#info=A second load balancer.
info=Ajp13 forwarding over socket
#info=A second tomcat instance.
#info=A second channel connecting to localhost:8019 via unix socket
info=The jni channel, used if tomcat is started inprocess
info=Status worker, displays runtime informations
info=Parameters used to load a JVM in the server process
info=Command to be executed by the VM on startup. This one will start tomcat.
info=Command to be executed by the VM on shutdown. This one will stop tomcat.
info=Display status information and checks the config file for changes.
#info=Example virtual host. Make sure myVirtualHost is in /etc/hosts to test it
#info=Example webapp in the virtual host. It'll go to lb_1 ( i.e. localhost:8019 )
info=Example webapp in the default context.
#info=A second webapp, this time going to the second tomcat only.
info=Map the whole webapp
info=Exampel with debug enabled.
Cut and paste the following jk2.properties file into the TOMCAT_HOME\conf directory. (Edit paths to suit)
## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE TOMCAT IS STOPED
## WHEN YOU EDIT THE FILE.
## COMMENTS WILL BE _LOST_
## DOCUMENTATION OF THE FORMAT IN JkMain javadoc.
# Override the default port for the socketChannel
# Just to check if the the config is working
# In order to enable jni use any channelJni directive
channelJni.disabled = 0
# And one of the following directives:
# If set to inprocess the mod_jk2 will Register natives itself
# This will enable the starting of the Tomcat from mod_jk2
You must reboot to make all the variables active
Remember Tomcat does not run as a service in this version so you don’t have to start it. It will start when called by Apache and run in process with it. You should set the Tomcat service to manual and not automatic.
ippee now we get to test it
all, keep your fingers crossed. Click
on http://localhost/examples. If you have been very, very good and shared
your candy with the other children then you should see the familiar tomcat example
directory. If the examples worked then
check out the extra cool jkstatus page at
If not, well then, you don’t play well with others, so go back to the start, erase everything and start over. LOL.
1. Take all the defaults during installation, except for the install paths. Choose custom install and change the Apache install directory to C:\ this will in fact install it to c:\Apache2, and Tomcat to c:\Tomcat, java to c:\Java.
2. Stop Apache and place mod_jk2.dll in the APACHE_HOME/modules directory.
3. Edit httpd.conf, add LoadModule jk2_module modules/mod_jk2.dll to the end of the LoadModules section.
4. Add system environment variables and modify system PATH.
Add to system PATH c:\Java;c:\Java\bin
5. Add a jk2.properties file to TOMCAT_HOME\conf and edit paths. File is here, use with no changes.
6. Add a workers2.properties file to APACHE2_HOME\conf and edit paths. File is here, do not change.
7. Create three empty files in the APACHE2_HOME\logs directory
8. Reboot system.
9. Give it a whirl http://localhost/examples
If You Have Trouble
If Apache fails to start, and it was fine before you started this, then there is probably something wrong with the LoadModule line you added to the httpd.conf. Open a cmd window in the bin directory of Apache and type in “apache –t” without the quotes. This will check the syntax of the httpd.conf file. If the LoadModule syntax is correct you may have the wrong mod_jk2.dll installed. It should throw an error complaining about incorrect versions in the cmd window.
Review the Apache error log to see problems with the in-process startup of Tomcat. If it complains about not finding the jvm.dll and can’t finish the vm setup or says there’s no installed jvm.dll in the path then check to make sure the JRE got installed correctly. Tomcat reads the registry to find the location of the jvm.dll. For example since I took the defaults during the installation of J2SDK my registry shows the installed JRE at;
[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.4.0_01]
Navigate to the indicated RuntimeLib directory and see if it’s actually there. If everything thing looks fine and it still throws errors then you can point mod_jk2 to it with a path statement in the [vm] section of the worker2.properties file, but normally this is not needed.
Mod_jk2 can tell you allot about your installation and configuration. You can see what it thinks at http://locahost/jkstatus.
Check the stdout and stderr logs for more clues, pay attention to the [error] lines, [warning] are ok.
Other problems I’ve seen is jk2 complaining that it can’t find the class path for Tomcat starter, this turned out to be a mangled mod_jk2.dll and was fixed by simply replacing the file.
If you get errors about AJP13 forwarding then check your jk2.properties file for a “channelJni.disable=0” statement. Jni has to have a channel statement to run. Any channelJni statement will do, the previous one simply says it is not disabled.
Did you remember to reboot? More than once I have forgotten this simple step, and without it Tomcat will not be able to find the jvm.dll or any of the other java stuff.
Double-check your environment variables for the correct paths. Make sure you have a tomcat-jni.jar in the TOMCAT_HOME/bin directory. Make sure the paths are correct in the jk2.properties and the workers2.properties file. The path for the jk2.shm should be correct, especially important if you have multiple processors.
BTW, if you use this “How to” and improve on it, how’s about sharing it back with me. email@example.com
I put this together after lurking on Tomcat-users and picking up some pointers from Malden Turk, Andy Eastham, and lots of others.
Senior Unix Administrator
Western Geographic Science Center
Get some humor too, sometimes it helps to take a break and laugh at yourself.