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/workers.properties and give it the following content:

  1. #
  2. # The workers that jk should create and work with
  3. #
  4. worker.list=ajp13
  5.  
  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
  11. worker.ajp13.host=localhost
  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/mod_jk.so
  4. # Where to find workers.properties
  5. # Update this path to match your conf directory location (put workers.properties next to httpd.conf)
  6. JkWorkersFile /etc/apache2/other/workers.properties
  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] "
  17.  
  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

Comments

16 Responses to “Installing mod_jk for Apache 2.2 on Mac OS X 10.5 Leopard”

  1. razmaspaz on May 7th, 2009 1:49 pm

    Would this work for JBoss too, I can’t remember if mod_jk is specific to Tomcat or if it is for all java servers

  2. Rich on May 15th, 2009 2:49 pm

    Thanks for the info, I ran into the same issues you did when trying to build for Leopard.

    @razmaspaz – Assuming you’re using Apache 2 to talk with jbossweb/tomcat (the default web server in JBoss) this should work fine. That’s what I’m doing. Apache 2.2 -> JBoss 5

  3. Ashok on August 26th, 2009 2:45 pm

    Thanks so much for these instructions. Made my life a lot easier!

  4. Jean-Luc metzger on December 16th, 2009 9:53 am

    Hello,
    Thanks for your post. I find it very usefull. But there is a little error inside. Could you change the flag arch to ppc64 as ppc_64 or PPC_64 does not existe and leads to the following error :
    checking for C compiler default output file name… configure: error: C compiler cannot create executables

    Cheers
    JLuc

  5. Bart B on December 27th, 2009 4:29 pm

    Thanks Jean-Luc, I’ve edited the post to fix the mistake.

    Bart.

  6. Tamas on April 25th, 2011 5:43 am

    Thanks a lot Bart. You saved hours of my life. I confirm that above works as is for JBoss 6 and OS X 10.6.7 too.

    Tamas

  7. Bart B on April 25th, 2011 9:02 pm

    Thanks for reporting back Tamas, great to know these instructions are still good on Snow Leopard!

    Bart.

  8. Ray H on October 9th, 2011 2:55 am

    Doing this on OSX 10.6.8 with native Apache2 and Tomcat 7.0.21. Only ran into one issue so far. Didn’t have Xcode installed so I didn’t have “make”. Downloading Xcode now and should be back on the road soon. Will let you know how it goes. Thanks for the article!

  9. Vince C on October 30th, 2011 5:04 pm

    Just finished doing this with OS X Lion, Tomcat 7.0.22, and mod_jk 1.2.32 and all works exactly as described in the tutorial. Thanks! This saved me much Googling.

  10. Bart B on November 1st, 2011 9:27 pm

    Hi Vince,

    Thanks for letting me know these instructions are still good in 10.7!

    Bart.

  11. Mikael Lindström on March 31st, 2012 6:00 am

    Hi

    Im new at using Xcode and i have a question that perhaps isnt directly connected to mod_jk. Can you “make” the mod_jk on one mac and use it on another? or does the make have to take place on the machine that it supposed tu use the files?

    i have a server that i want to use what you describe in your posts here, do i have to install Xcode on the server or can i use my macbook to make the mod_jk and then move files over to the server?

    Regards
    Mikael

  12. Bart B on April 8th, 2012 1:46 pm

    Hi Mikael,

    I haven’t done it myself, but in theory, if the Macs have the same OS and the same CPU architecture, then yes, you should be able to make on one and install on many.

    Bart.

  13. Mario on October 16th, 2012 10:05 am

    Hi and thanks for this precious guide!
    It works on Mountain Lion too!
    The only stop is when you try to create the executable, you get checking for C compiler default output file name… configure: error: C compiler cannot create executables.
    The issue is the missing folder OSX10.8.xctoolchain into /Applications/Xcode.app/Contents/Developer/Toolchains
    In MacOs 10.8 it is called XcodeDefault.xctoolchain.
    I simply copied and renamed this one!

  14. Amit G on May 7th, 2013 10:23 am

    Thanks for this article. It worked on my first attempt itself.

  15. dimitryous r. on May 12th, 2013 6:41 am

    Hi Bart! Thank you for this detailed instructions. For my part it doesn’t work: Mac 10.8.3, Apache Tomcat 7.0.34, Apache/2.2.22, Xcode 4.6.2 … Tried combinations of ./configure, “Mario’s (October 16th, 2012 10:05 am)” with OSX10.8.xctoolchain stuff in Xcode… no success.
    All that stuff at /usr/local/tomcat-connectors-1.2.37/native/
    Always the same message: checking for C compiler default output file name… configure: error: C compiler cannot create executables
    No chance, no luck!
    Tried and install dnsmasq with help at http://www.justincarmony.com/blog/2011/07/27/mac-os-x-lion-etc-hosts-bugs-and-dns-resolution/ (just in case)…
    The last line of config.log: configure: exit 77 (???)
    No mod_jk… grhhhhh!

  16. dimitryous r. on May 12th, 2013 7:48 am

    Hi Bart!
    Surfing around the web gave me the solution :
    http://apple.stackexchange.com/questions/58186/how-to-compile-mod-wsgi-mod-fastcgi-etc-on-mountain-lion-by-fixing-apxserror
    i.e. sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain

    It works…
    Thanks you all!

Leave a Reply




Before you post a comment please remember that commenting on my blog is a privilege not a right. I won't approve comments that are obscene, offensive or insulting. For more info please read this post.

Subscribe without commenting