In order to get this done, you’ll need Apache, Tomcat, and the MOD_JK connector library. I’ve included the Windows binaries below, as I’m writing this blog post from a Windows machine. Feel free to swap out these downloads with whatever RPM, YAST, APT, etc. commands you want. Also, you’ll need to have a Java JDK installed, and your JAVA_HOME pointing to it. Make sure your path contains %JAVA_HOME%/bin.
Download and Apache from here: http://apache.mirrors.tds.net/httpd/binaries/win32/apache_2.2.14-win32-x86-no_ssl.msi
Download and extract Tomcat from here: http://mirrors.axint.net/apache/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.zip
Download MOD_JK from here: https://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.28/mod_jk-1.2.28-httpd-2.2.3.so
- Install Apache.
- Copy the mod_jk-1.2.28-httpd-2.2.3.so file to your apache/modules directory.
- Add the following to your apache/conf/httpd.conf ``` LoadModule jk_module modules/mod_jk-1.2.28-httpd-2.2.3.so JkWorkersFile conf/workers.properties JkLogFile logs/jk.log JkLogLevel debug JkMount /* router JkMount /jk_status status ```
- Create a workers.properties file in your apache/conf directory. The file should contain the following: ``` worker.list=router,status worker.worker1.port=8109 worker.worker1.host=localhost worker.worker1.type=ajp13 worker.worker1.lbfactor=1 worker.worker1.local_worker=1 worker.worker1.sticky_session=0 worker.worker2.port=8209 worker.worker2.host=localhost worker.worker2.type=ajp13 worker.worker2.lbfactor=1 worker.worker2.local_worker=0 worker.worker2.sticky_session=0 worker.worker3.port=8309 worker.worker3.host=localhost worker.worker3.type=ajp13 worker.worker3.lbfactor=1 worker.worker3.local_worker=0 worker.worker3.sticky_session=0 worker.router.type=lb worker.router.balanced_workers=worker1,worker2,worker3 worker.router.local_worker_only=1 worker.status.type=status ```
-
Extract the Tomcat installation ZIP archive to three different directories, as we're going to load balance three instances of Tomcat. You'll be replacing the server.xml file in each of the Tomcat conf/ directories with the following:
```
- Start (or Restart) Apache
- Start each instance of Tomcat (use the startup script in the Tomcat /bin directory) - you should see no errors.
- Verify each Tomcat is working by opening a browser window to each Tomcat instance - if you've followed my instructions, the links are: http://localhost:8180/examples/servlets/, http://localhost:8280/examples/servlets/, and http://localhost:8380/examples/servlets/.
- If Tomcat started correctly, start Apache. You should be able to access the Tomcat example pages via the following URL: http://localhost/examples/servlets/
- You're done. Using my configuration, you can access a page to control the JK connector here: http://localhost/jk_status, I'd recommending hiding and protecting this should you want to put this configuration into production. Try experimenting with the configuration by stopping instance of Tomcat... as long as one instance of Tomcat is running, you should be able to see the examples.