Technology, Uncategorized 0 comments on Installing Tomcat 5.5.17 and Mod_Jk 1.2.5 on Apache 1.3 for Mac OS 10.4

Installing Tomcat 5.5.17 and Mod_Jk 1.2.5 on Apache 1.3 for Mac OS 10.4

I’ve seen a general lack of content on the latest versions of Tomcat and how to install it on the Mac operating system. This is really frustrating when you don’t know what you’re doing, and you just need some help. After compiling a bunch of how-tos into my memory, I decided to go ahead and post one myself that might help others out.

The latest versions of the software involved were found at these links:

I’ve posted this zip file which comes with all the files you will need for Tomcat including the deployer, admin-related folders, and compatibility package in case you’re still on Java 1.4

On to the install…

Installing Tomcat

  1. I’m assuming that you unzipped the zip package on your Desktop. Given that this is true, it’s probably best to move it to your /usr/local/ folder, and then create a symlink to it in your Library. This is pretty simple to do.
    • sudo cp -rf apache-tomcat-5.5.17/ /usr/local/apache-tomcat-5.5.17/
      • Note: You need to know your administrator password, and either su into the terminal or use the sudo command
    • ln -s /usr/local/apache-tomcat-5.5.17 /Library/Tomcat
      • This creates a symlink to which you can point any version of Tomcat as newer versions are released, or older versions need to be tested
  2. Next let’s go ahead and setup your bash environment
    • Head to your home directory and enter the following lines into a .bash_profile file
      • export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/
        Versions/CurrentJDK/Home
      • export CATALINA_HOME=/Library/Tomcat
  3. The environment is setup. Now we need to setup the start and stop files for Tomcat. This is borrowed from Apple’s how-to on setting up Tomcat.
    It’s suggested to go ahead and setup a bin folder in your home directory, and I did this because it starts organizing your scripts. The content of the files should look like this:
    • startup.sh
      • #!/bin/sh
      • $CATALINA_HOME/bin/startup.sh
    • shutdown.sh
      • #!/bin/sh
      • $CATALINA_HOME/bin/shutdown.sh
    • Then execute the following command
      • chmod ug+x start_tomcat stop_tomcat
  4. If everything has been configured correctly, then you can go ahead and go to http://localhost:8080 and see a running instance of Tomcat. Congratulations!

Configuring Mod_JK

So, it turns out that I was making this way too difficult. It is in fact quite simple to get mod_jk working on your computer. You do need some knowledge of how Apache works, and enough permissions to set some things ups on your computer, but I’m sure you already have that if you’re reading this tutorial. On with the installation:

  1. Move the mod_jk.so file that you should have downloaded as a binary into the appropriate folder with the following command:
    • sudo cp {CURRENT_PATH_TO_MOD_JK.SO}/mod_jk.so /usr/libexec/httpd/mod_jk.so
  2. To setup the workers.properties file, take the following steps:
    • cd $CATALINA_HOME/conf
    • sudo touch workers.properties
    • sudo vi workers.properties
    • Type in the following to setup the workers.properties file
      • worker.list={any_username}
      • worker.{any_username}.type=ajp13
      • worker.{any_username}.host={HOSTNAME_OF_SERVER}
      • worker.{any_username}.port=8009
    • Mine looks like this:
      • worker.list=tomcat
      • worker.tomcat.type=ajp13
      • worker.tomcat.host=localhost
      • worker.tomcat.port=8009
  3. Now let’s move on to setup the Apache HTTP server. Move to the Apache configuration directory to update httpd.conf.
    • cd /etc/httpd
    • sudo vi httpd.conf
  4. And now let’s add the following lines to the httpd.conf file
    • LoadModule jk_module libexec/mod_jk.so
    • AddModule mod_jk.c
    • JkWorkersFile {CATALINA_HOME}/conf/workers.properties
    • JkLogFile {CATALINA_HOME}/logs/mod_jk.log
    • JkLogLevel error
  5. Now let’s add the VirtualHost necessary to mount the paths. Type the following into your httpd.conf file
    • <VirtualHost {HOSTNAME_IN_WORKERS_FILE}>
    • DocumentRoot {DIRECTORY_YOUR_HTML_FILES_ARE_IN}
    • JkMount /{webapp_name}/* {any_username}
    • JkMount /{webapp_name} {any_username}
    • </VirtualHost>

There you go, now you should be able to restart Apache and have Tomcat working through Apache serving both your dynamic and static content.