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:

$ cd native
$ ./configure CFLAGS=’-arch x86_64′ APXSLDFLAGS=’-arch x86_64′ –with-apxs=/usr/sbin/apxs
$ make
$ 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:

# The workers that jk should create and work with

# Defining a worker named ajp13 and of type ajp13
# Note that the name and the type do not have to match.

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:

# Load mod_jk module
# Update this path to match your modules location
LoadModule jk_module libexec/apache2/
# Where to find
# Update this path to match your conf directory location (put next to httpd.conf)
JkWorkersFile /etc/apache2/other/
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /var/log/apache2/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] ”

# Send everything for context /example to worker named ajp13
JkMount /example/* ajp13

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

Then just restart Apache to load up the new configuration: