mod_jk Fail, mod_proxy Success
November 14th, 2008 at 11:31 pm by Michael ScepaniakI have a production site configured with Apache2 forwarding requests to Tomcat using mod_jk. I wanted to mimic this configuration on my desktop environment, but was not able to get it to work locally on my Mac. I ended up using mod_proxy locally instead. This is the ordeal I went through…
I grabbed a binary for Mac OSX (x86) from the Tomcat Connectors site, renamed it to mod_jk.so, and dropped it in the directory with the other modules. I made the necessary changes and additions to the Apache config files. Unfortunately, when I started Apache, I received the following error:
no suitable image found. Did find: /usr/libexec/apache2/mod_jk.so:
mach-o, but wrong architecture
Googling the error helped me realize that I wasn’t alone with my issue and I figured out that I needed to build mod_jk from source, passing in some special flags to the build:
./configure CFLAGS='-arch x86_64' APXSLDFLAGS='-arch x86_64'
-with-apxs=/usr/sbin/apxs
This was great, but the next step (i.e., “make”), kept failing for me:
jk_global.h:66:21: error: apr_lib.h: No such file or directory
jk_global.h:67:25: error: apr_strings.h: No such file or directory
make[1]: *** [jk_ajp12_worker.lo] Error 1
make: *** [all-recursive] Error 1
I found lots of other pages explaining further variations of the same basic premise that I needed to build from source:
- http://de-co-de.blogspot.com/2008/04/if-you-install-modjk.html
- http://egopoly.com/2007/10/29/how-to-install-tomcat-mod_jk-on-mac-os-x-leopard/
- http://blog.lo-fi.net/2007/10/leopard-for-web-developer-installing.html
I followed all of these instructions, but still had no luck. Then I tried going down the DarwinPorts path:
But I didn’t get anywhere with this:
mike$ sudo port install mod_jk
...
Configuring APR library
Platform: i386-apple-darwin9.4.0
checking for working mkdir -p... yes
APR Version: 1.3.2
checking for chosen layout... apr
checking for gcc... /usr/bin/gcc-4.0
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
I came to suspect that I might require an install of Apple’s Xcode to get any of these solutions to work. So I started downloading it. As I was waiting for the download to complete, I started looking at mod_proxy as an alternative to mod_jk. Using mod_proxy wouldn’t accomplish my goal of mirroring the production configuration and I wasn’t sure if it could handle sticky sessions, but I didn’t need that at this point. So I gave it a whirl, fought with it a little bit, and eventually was able to configure a solution before I got anywhere with Xcode:
In Apache’s httpd.conf:
<Proxy balancer://myCluster>
BalancerMember ajp://dev.milestoneinc.com:8010 route=node1
</Proxy>
ProxyPass /blogs !
ProxyPass /balancer-manager !
ProxyPass / balancer://myCluster/ stickysession=JSESSIONID
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
In Tomcat’s server.xml:
<Engine defaultHost="localhost" jvmRoute="node1" name="Catalina">
More information regarding mod_proxy and load-balancing/session-affinity:
- http://www.darkcoding.net/2006/02/page/2/
- http://wiki.apache.org/cocoon/LoadBalancingWithModProxy
- http://www.nabble.com/mod_ajp-and-Load-Balancing-Issue-td18283072.html
- http://www.theserverside.com/tt/kno…er.tss?l=LoadBalancingTomcatApache
- http://www.markround.com/archi…ncing-with-PHP-sticky-sessions.html
If you enjoyed this post, you might want to follow this blog!
April 6th, 2009 at 5:09 am
[...] Unfortunately the version available at the apache site (1.2.25) : http://apache.org/dist/tomcat/tomcat-connectors/jk/binaries/macosx/ is not compatible with Leopard. [...]