12

I am looking for a correct way to install mod_jk on Mac OS X 10.7 Lion or above. The goal is to test Tomcat behind Apache HTTPD.

I've found so far the only way to install mod_jk is to download source then configure it in the console and make and make install.

This is not very true because I will need to manage mod_jk installation and configuration myself. I for example can forget to delete mod_jk later when needed. Anyway I think there should be more friendly way to install mod_jk like some kind of DMG package.

I also found that mod_jk is available in the OS X Server. Actually it's on my development machine, but available only for the server.

<IfDefine MACOSXSERVER>
...
#LoadModule jk_module libexec/apache2/mod_jk.so
...
</IfDefine MACOSXSERVER>

May be there is a package for mod_jk somewhere for developers who don't install OS X Server or any other way.

UPDATES

  1. mod_proxy_ajp is an alternative. Main Pros: it's bundled with Apache and Mac OS X
  2. I now tested mod_proxy_ajp in my configuration and can say that it's even better - because no need extra configuration. mod_proxy_ajp goes out of the box on Mac and perhaps on linux-server too I believe. You also don't need to use extra workers.properties file.

Here is how my config looks like:

<VirtualHost *:80>
    ServerAdmin me@me.com
    DocumentRoot "/Users/me/Sites/projekt"
    ServerName projekt.local

    <Directory "/Users/me/Sites/projekt">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    <Proxy *>
      AddDefaultCharset Off
      Order deny,allow
      Allow from all
    </Proxy>

    ProxyPass /coolapp ajp://localhost:8009/coolapp
    ProxyPassReverse /coolapp ajp://localhost:8009/coolapp

    ErrorLog "/private/var/log/apache2/projekt.local-error_log"
    CustomLog "/private/var/log/apache2/projekt.local-access_log" common    
</VirtualHost>

This above and configured Tomcat with AJP connector is only what you need. Amazing!

Reference:

  1. Install mod_jk on OS X - http://www.bartbusschots.ie/blog/?p=1347
  2. Comparison mod_jk vs. mod_proxy_ajp apache to tomcat: mod_jk vs mod_proxy
  3. How to configure mod_proxy_ajp with Tomcat ?

Please suggest.

Community
  • 1
  • 1
Vladimir
  • 4,782
  • 7
  • 35
  • 56
  • What "config file" do you refer to? Does the text you show, beginning `` go into `httpd.conf` or somewhere else? – murray Apr 26 '13 at 20:27
  • @murray - the config goes in /etc/apache2/extra/httpd-vhosts.conf for me. But you can also manage to it somewhere else when it's appropriate, for example in users config - /etc/apache2/users/... I decided for myself that this httpd-vhosts.conf fits better for my installation. – Vladimir Apr 27 '13 at 09:43
  • I don't understand what the "`/coolapp`" refers to. What's the relation of that to the `DocumentRoot` setting? – murray Apr 27 '13 at 19:53
  • What's the syntax for the `LoadModule` line that goes into `httpd.conf` for `mod_proxy_ajp`? That is, what is "`xxx`" in `LoadModule xxx modules/mod_proxy_ajp.so`? – murray Apr 27 '13 at 20:06
  • To answer my question about the `LoadModule` syntax, what seems to work is: `LoadModule proxy_ajp_module modules/mod_proxy_ajp.so`. – murray Apr 28 '13 at 00:16
  • To answer my question, what seems to work is: `LoadModule proxy_ajp_module modules/mod_proxy_ajp.so`. – murray Apr 28 '13 at 00:16
  • To answer my question about "/coolapp", I figured out that this can be just a subdirectory of the `webapps` directory; and indeed it can be merely `/` to indicate `webapps` itself. – murray Apr 28 '13 at 00:18
  • @murray When you deploy a webapp on Tomcat - the app gets url according to the app name like /coolapp, /myapp. It's also easier to manage when you want to deploy different apps on the same server. And yeah - technically webapp dir is root place for different apps. – Vladimir Apr 30 '13 at 17:55

1 Answers1

14

You can give mod_proxy_ajp a shot. It does AJP13 and load balancing just like mod_jk but ships with Mac OS X.

Philippe Marschall
  • 4,452
  • 1
  • 34
  • 52
  • Cool - I didn't know about it - will check. How you can compare them? – Vladimir Jul 29 '12 at 19:33
  • Looks like here is the difference - http://stackoverflow.com/questions/1081918/apache-to-tomcat-mod-jk-vs-mod-proxy – Vladimir Jul 29 '12 at 19:36
  • Great - it works out of the box and is even easier to configure, e.g. no extra workers.properties file needed. Thank you @Philippe. Looks like answer from the real Philippe Marschall from Seaside Community - cool. – Vladimir Jul 29 '12 at 20:12
  • Thanks, I was failing on mod_jk on Mac, too. But That worked straight out of the box. – Kai Mattern Aug 01 '13 at 08:29
  • Seems the High Sierra mod_proxy_ajp got a problem. Some XML data posted to the server contains a leading special character, which causes XML parsers in Tomcat to fail. I needed to switch to HomeBrew httpd to fix this problem. – Bertl Dec 05 '17 at 09:51