Automated Tomcat / mod_jk / Apache httpd Setup

Home, Elsternwick, Australia, 2007-11-25 11:43 +1000

#infrastructure #software_engineering

Getting Apache HTTPD and Tomcat to talk to each other via mod_jk is one of those things that always seems to be a painful task. I think this is because of two things. First, there are innumerable ways of configuring Apache HTTPD, and the locations and names of the configuration files may differ depending on your Linux distro, and who built your Apache binaries. Second, while there are many explanations of how to set up HTTPD / mod_jk / Tomcat, most explanations are copy-and-paste configuration dumps with not much explanation of how it all hangs together and what all the configurations mean.

In fact setting up Apache and Tomcat together is very simple once you understand the underlying concepts. Here I’m going to attempt to provide a tutorial on how to setup these two services and also explain what the configurations all mean. I’ll also discuss the way that I’ve arranged my data and configuration files to keep them separated out so that they can be easily backed up and migrated to new hosts as required.

  • Install Debian using preseed.cfg
  • Install Java
  • Install Tomcat
  • Install mod_jk.so into Apache
  • Add workers configuration to Apache
  • Link virtual hosts into Apache
  • Link virtual hosts into Tomcat
  • Add JkMount directives to Apache virtual host configurations

Script

Install Java

wget http://buildsrv.x1seven.com:21880/scripts/install_jse-sdk-1.6.0_03.sh
chmod 700 install_jse-sdk-1.6.0_03.sh
./install_jse-sdk-1.6.0_03.sh

Install Tomcat and mod_jk

wget http://buildsrv.x1seven.com:21880/scripts/install_tomcat-6.0.14.sh
chmod 700 install_tomcat-6.0.14.sh
./install_tomcat-6.0.14.sh

Install JSPWiki

wget http://buildsrv.x1seven.com:21880/scripts/install_jspwiki-2.4.104.sh
chmod 700 install_jspwiki-2.4.104.sh
./install_jspwiki-2.4.104.sh

Install Virtual Hosts into Tomcat

<!DOCTYPE Server [
        <!ENTITY virtual_host_com.x1seven.www SYSTEM "/dat/com.x1seven.www/tomcat/conf/virtual_host.xml">
]>
                        &virtual_host_com.x1seven.www;