How to Connect Tomcat to Apache via mod_webapp on SME

Author:  David S. Helmuth <dave@helmuth.net>

Contributor:
  Kevin Yank, Well, he didn't really contribute, but I stole most of the information that I needed for how to configure mod_webapp from:
http://www.webmasterbase.com/article/305/44.  Great article for the a newbie like me.

Release supported: e-smith 4.x, SME 5.x

License: GPL

Last updated: Saturday, January 04, 2003 06:27 AM

 


Problem:  You need to install and use a server that can support Java Servlet and Java Server Pages.  You want Java stuff handled by Tomcat and HTML handled by Apache.

Solution:  This initial HowTo for Apache/Tomcat Integration.

What You Get: A basic integration of Apache and Tomcat.   What I am assuming in this HowTo is that you want to fully incorporate the delivered sample WebApps into the Apache Web Server on SME.  Note that we are using the WebAppConnection method (mod_webapp) not mod_jk.  What that means is that the basically, all requests for JSP are sent to Tomcat.  However basic connection such as a secure connection, are handled by Apache.

What is mod_webapp?:  http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/webapp.html


Color/table conventions: 

White text/Black background indicates these are commands that should be executed at the command line.

White text/gray background indicates the information should be place in a text file

Server Manager Settings 

SME Server Manager Screen Name
Setting Value
??? ???

Step 1:  Follow this HowTO for installing the Sun JDK (Java Development Kit). 


Step 2:  Follow this HowTO for installing the Tomcat 4.0. (Note that I have not really worked toward getting the integration working on 3.3.  I just moved over to 4.0 and started from there.)


STEP 3:  Install the RPM for the mod_webapp connector.

rpm -Uvh http://jakarta.apache.org/builds/jakarta-tomcat-4.0/archives/v4.0.2-b2/rpms/mod_webapp-1.0.2-1.i386.rpm

Note:  This RPM install will some lines to the end of you httpd.conf.  Unless you are sure you re-expand it at the end of this HowTo, you will most likely have problems.


STEP 4:  Create the template-custom directory that will be needed.

mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf


STEP 5: Go to the template directory

cd /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf


STEP 6: Edit the "basic" template fragments.

pico 20LoadModule81mod_webapp

LoadModule webapp_module modules/mod_webapp.so

Save and exit PICO.

pico 30AddModule61mod_webapp

AddModule mod_webapp.c

Save and exit PICO.

pico 98TomcatForward

#------------------------------------------------------------
# Tomcat Connection Information for Apache
#------------------------------------------------------------

WebAppConnection warpConnection warp localhost:8008

Save and exit PICO.


STEP 7: Setup the template fragments for the various "webapps" that you are going to use.  Back to our example, we are setting up the "sample webapps" that come with Tomcat.

pico 99000TomcatWebApp

#------------------------------------------------------------
# Tomcat WebApp Information for Apache
#------------------------------------------------------------

Note:  Basically I putting all of the various webapps into their own fragment.  That should make adding new ones much easier later. Here is a series of them:

pico 99001TomcatWebAppexamples

WebAppDeploy examples warpConnection /examples

pico 99002TomcatWebAppROOT

WebAppDeploy ROOT warpConnection /ROOT

pico 99003TomcatWebApptomcat-docs

WebAppDeploy tomcat-docs warpConnection /tomcat-docs

pico 99004TomcatWebAppwebdav

WebAppDeploy webdav warpConnection /webdav

Note:  Be sure to save between each one.


STEP 8: Expand you httpd.conf

/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf


STEP 9:  Ensure that the Apache-Connector Service is enabled.  It appears to be commented out by default in the version that we load above.

pico /etc/tomcat4/server.xml

Look for the text that looks like the following (it is at the end of the file):

 

<!--
<Service name="Tomcat-Apache">

<Connector className="org.apache.catalina.connector.warp.WarpConnector"
port="8008" minProcessors="5" maxProcessors="75"
enableLookups="true" appBase="webapps"
acceptCount="10" debug="0"/>

<Engine className="org.apache.catalina.connector.warp.WarpEngine"
name="Apache" debug="0">

<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>

<Realm className="org.apache.catalina.realm.MemoryRealm" />

</Engine>

</Service>
  -->

Change it to:

 

<Service name="Tomcat-Apache">

<Connector className="org.apache.catalina.connector.warp.WarpConnector"
port="8008" minProcessors="5" maxProcessors="75"
enableLookups="true" appBase="webapps"
acceptCount="10" debug="0"/>

<Engine className="org.apache.catalina.connector.warp.WarpEngine"
name="Apache" debug="0">

<Logger className="org.apache.catalina.logger.FileLogger"
prefix="apache_log." suffix=".txt"
timestamp="true"/>

<Realm className="org.apache.catalina.realm.MemoryRealm" />

</Engine>

</Service>

Note:  All we are doing it "uncommenting" a section of the file.


STEP 10: Restart/start the various servers:

service tomcat4 restart
service httpd restart


STEP 11: Fix the links in index.jsp

pico /var/tomcat4/webapps/ROOT/index.jsp

On about line 83 you will find the following section:

<a href="tomcat-docs/">Tomcat Documentation</a><br>

Make it look like this:

<a href="/tomcat-docs/">Tomcat Documentation</a><br>

On about line 116 you will find the following section:

<a href="examples/jsp/">JSP Examples</a><br>
<a href="examples/servlets/">Servlet Examples</a><br>
<a href="webdav/">WebDAV capabilities</a><br>

Make it look like this:

<a href="/examples/jsp/">JSP Examples</a><br>
<a href="/examples/servlets/">Servlet Examples</a><br>
<a href="/webdav/">WebDAV capabilities</a><br>

On about line 153 you will find the following section: (Note it is a link buried in some in-line text, we are doing the same thing we did before, adding a "/" in front of it.

<a href="tomcat-docs/">

Make it look like this:

<a href="/tomcat-docs/">

Note:  Changing the links to fix them from generating w/ "ROOT" in everything.  Also, at the top of that ROOT Tomcat page, there are two links to the Tomcat Administration, and the Tomcat Manager.  Those links are NOT enabled with this method!  You will still need to go to http://sme-server:8080/ to utilize those!


STEP 12: Start Looking Around:

http://sme-server/ROOT/ is the start page for the looking around, there are some good links from there to various sites and some good examples.  Here are all the webapps you just installed:

http://sme-server/ROOT/
http://sme-server/examples/
http://sme-server/tomcat-docs/
http://sme-server/webdav/

Note:  Please replace sme-server with the appropriate host name of your sme-server. Also, you must include the trailing "/" in the URL.


To-do's: (Not necessarily in order of importance)

 http://www.helmuth.net/mitel-sme/JetSpeed/jetspeed-howto.htm

Enjoy!