Note: these instructions also work on OS X 10.6 Snow Leopard, and OS X 10.7 Lion

A few years ago I did a similar tutorial for installing mod_jk on OS X 10.4 Tiger, but yesterday I discovered that those instructions do not work for Leopard. It took my quite a bit of googling and trial an error, but I’ve found a solution that works, which I’m going to share here. This solution is, in my opinion, a best practices solution, and does not involve any changes to your core apache configuration file (httpd.conf). These instructions are for the default install of Apache 2.2 that comes pre-installed on OS X 10.5 Leopard. I can verify that these instructions work for Tomcat 5.0.30, but I would be 99% sure they should also work un-changed for Tomcat 5.5.X and Tomcat 6.0.X.

The obvious first step is to download the latest version of the mod_jk Connector from the Apache site (download the .tar.gz source file). I tested these instructions using version 1.2.28. Once you have the file downloaded extract it by double-clicking it in the Finder. Then launch the Terminal and change into the folder you just extracted from the .tar.gz file. From this location execute the following commands:

  1. $ cd native
  2. $ ./configure CFLAGS='-arch x86_64' APXSLDFLAGS='-arch x86_64' --with-apxs=/usr/sbin/apxs
  3. $ make
  4. $ sudo make install

Please note that these instructions are for 64bit Intel machines (Core 2 Duo and above), if your machine has a 32bit Intel processor (e.g. Core Duo or Core Solo) replace all instances of x86_64 with i386, similarly 32bit PowerPC users (i.e. G4 users) should replace all instance of x86_64 with ppc, and 64bit PowerPC users (i.e. G5 users) with ppc64.

If the above Terminal commands execute without errors you have successfully compiled and installed mod_jk. In order to start using it you will need to do two more things. Firstly, you will need to create the file /etc/apache2/other/ and give it the following content:

  1. #
  2. # The workers that jk should create and work with
  3. #
  4. worker.list=ajp13
  6. #
  7. # Defining a worker named ajp13 and of type ajp13
  8. # Note that the name and the type do not have to match.
  9. #
  10. worker.ajp13.type=ajp13
  12. worker.ajp13.port=8009

And secondly, you will need to create the file /etc/apache2/other/mod_jk.conf and give it content something like the following, substituting in your own JkMount directives at the end:

  1. # Load mod_jk module
  2. # Update this path to match your modules location
  3. LoadModule jk_module libexec/apache2/
  4. # Where to find
  5. # Update this path to match your conf directory location (put next to httpd.conf)
  6. JkWorkersFile /etc/apache2/other/
  7. # Where to put jk shared memory
  8. # Update this path to match your local state directory or logs directory
  9. JkShmFile /var/log/apache2/mod_jk.shm
  10. # Where to put jk logs
  11. # Update this path to match your logs directory location (put mod_jk.log next to access_log)
  12. JkLogFile /var/log/apache2/mod_jk.log
  13. # Set the jk log level [debug/error/info]
  14. JkLogLevel info
  15. # Select the timestamp log format
  16. JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
  18. # Send everything for context /example to worker named ajp13
  19. JkMount /example/* ajp13

That’s it, just verify that you don’t have any issues with your config by running:

$ sudo apachectl configtest

Then just restart Apache to load up the new configuration:

$ sudo apachectl restart