Sie sind auf Seite 1von 5

Tomcat-Apache HOWTO

This document explains how to connect Tomcat to the popular open source web server, Apache.
Other important documents:

Tomcat User's Guide


Tomcat FAQ
mod_jk HOWTO

Introduction

Need for cooperation

As stated in the Tomcat User's Guide, Tomcat currently supports three modes of execution.
While it is entirely possible to have Tomcat serve both your static and dynamic document
provision needs, there are several reasons why you might not want want to do this. With respect
to the Apache web server,

1. Tomcat is not as fast as Apache when it comes to static pages.


2. Tomcat is not as configurable as Apache.
3. Tomcat is not as robust as Apache.
4. Tomcat may not address many sites' need for functionality found only in Apache modules
(e.g. Perl, PHP, etc.).

For all these reasons it is recommended that real-world sites use an industrial-strength web
server, such as Apache, for serving static content, and use Tomcat as a Servlet/JSP add-on.

How will they work together?

In a nutshell a web server is waiting for requests. When these requests arrive the server does
whatever is needed to serve the requests by providing the necessary content. Adding Tomcat to
the mix may somewhat change this behavior. Now the web server needs to perform the
following:

Before the first request can be served, Apache needs to load a web server adapter library
(so Tomcat can communicate with Apache) and initialize it.

When a request arrives, Apache needs to check and see if it belongs to a servlet; if so it
needs to let the adapter take the request and handle it.
What's required to pull this off?

1. Install Apache 2.2

2. Modify Apache's httpd.conf file.

3. Install a web server adapter.

4. Modify Tomcat's server.xml file

Configuring Tomcat

The AJP Connector

This is the mechanism by which Tomcat will communicate with Apache.

Include in tomcat server.xml

<!ApacheAJP12support.Thisisalsousedtoshutdowntomcat.
>
<Connector
className="org.apache.tomcat.service.PoolTcpConnector">
<Parametername="handler"

value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler
"/>
<Parametername="port"
value="8007"/>
</Connector>

To ensure that it is indeed listening on that port, Telnet to it or HTTP request it. The
Ajp12ConnectionHandler will throw an exception (visible in the tomcat log file), and you'll
know it's listening. As far as the web server adapter goes, this is all you really need to know on
the Tomcat side for now.

The Web Server Adapter

The next step in integrating Apache with Tomcat is to install a web server adapter. This is the
piece of software that will relay information between Tomcat and Apache. It doesn't really
belong under Apache configuration, and it doesn't really belong under Tomcat configuration, but
it's required for both of them to work together.

mod_jk
It is a completely new Tomcat-Apache plugin that passed adaptation to Tomcat.

mod_jk.so

Put under Apache2.2\modules folder


httpd.conf - Apache's main configuration file

D:\Apache2.2\conf

Add the following to file

LoadModule jk_module modules/mod_jk.so

Include "%EM_HOME%/emweb/tomcat/conf/auto/mod_jk.conf"

Note: replace "%EM_HOME% with full path

Architecture Diagram

Das könnte Ihnen auch gefallen