Nov
14
Installing mod_jk for Apache 1.3 on Mac OS X 10.4 Tiger
Filed Under Computers & Tech, System Administration on November 14, 2006 at 4:25 pm
I’ve done a few previous articles on Apache Tomcat (one for installing it on Linux and one for installing it on OS X), but I haven’t yet mentioned installing the JK Connector (mod_jk
) in any environment. For those who are wondering what on earth I’m on about, mod_jk
allows the Apache web server to serve your Tomcat web apps so they appear on port 80. There are a number of reasons why you might want to do this. Firstly, it provides a simple and secure way to get Tomcat to respond to requests on port 80 without having to have it run as root. Apache is more efficient at serving static pages so it can help increase the efficiency of your web app, and finally it allows you leverage all the power of Apache’s many features for your Java web app.
[tags]Tomcat, Apache, OS X, Mac, mod_jk, Tomcat Connectors[/tags]
As I write this there is no binary version available for Apache 1.3 on Mac OS X so unless you’re using OS X server (or are running Apache2 on your regular OS X install) you’ll have to compile the code yourself. First you’ll have to grab the source from the Apache server and expand it to a folder on your machine. Then you’ll have to open up a terminal, get a root shell (sudo bash
) and then change into the folder native
inside the folder you got when you expanded the tar.gz
file. Here you have to configure the source to prepare to build it with the following command:
./configure --with-apxs=/usr/sbin/apxs
When that completes change into the folder apache-1.3
and actually compile the connector with:
cd apache-1.3 make -f Makefile.apxs
When the compile finishes you have to copy the library that was generated to the appropriate system folder and set the correct permissions on it:
cp mod_jk.so /usr/libexec/httpd/ chmod ugo+x /usr/libexec/httpd/mod_jk.so
At this point mod_jk
is installed and all you have to do now is configure it and configure apache to use it. The first thing we need to do is to create the workers property file which is generally saved as /usr/local/tomcat/conf/worker.properties
and should contain:
workers.tomcat_home=/usr/local/tomcat workers.java_home=/Library/Java/Home worker.list=myworker worker.myworker.type=ajp13 worker.myworker.host=localhost worker.myworker.port=8009 worker.myworker.socket_keepalive=1
Note: depending on your configuration you may need to change workers.tomcat_home and workers.java_home.
Now we have to tell Apache to load mod_jk and what tomcat folders to map to what Apache URLs. We do this by editing the apache config file which can be found in /etc/httpd/httpd.conf
. You need to add lines like the ones below after the AddModule
statements. Don’t add these lines just below the other LoadModule
statements above the AddModule
statements because that won’t work.
LoadModule jk_module libexec/httpd/mod_jk.so JkWorkersFile /usr/local/tomcat/conf/worker.properties JkLogFile /private/var/log/httpd/mod_jk.log JkLogLevel trace JkMount /* myworker
Note: this config will map all the webapps in your Tomcat install to apache. I.e. if you have a web app at http://my.server.ie:8080/myWebApp/
then it will now be mapped to http://my.server.ie/myWebApp.
Now just restart Apache and cross your fingers!
apachectl restart
This was very helpful but I couldn’t get 1.2.22 to build at all. Before ./configure would run for me, I had to convert line endings from DOS to Unix in the following files:
native/configure
native/scripts/build/unix/config.sub
native/scripts/build/unix/config.guess
native/scripts/build/unix/missing
After that make gave me some errors.
1.2.21 was ok though and seems to be working.
any comments for mac OS X 10.5?
Hi Zegabi, I haven’t upgraded my servers to Leopard yet so I’m afraid I can’t be of much help.
All I can say is that it should work but the version of Apache in Leopard is 2.2 so you’ll have to use the appropriate dir for that rather than for Apache 1.3.
If you do give it a go please post back here with how you get on.
Thanks,
Bart.
very helpful, thanks
I just figured it out for Mac OS X 10.5, with a little help from the blogsphere of course 😉 See my website http://www.toly.nl
[…] 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 […]
Great set of instructions – just what I needed!
Many thanks!
Great instructions , I followed them and ran into one error which says Cannont find Webserver.
I use 10.6.8 with mod_jk_1.2.37.
any help is appreciated.
thanks again
Dpa