How to integrate Apache and Tomcat to deploy Web apps

Source: Internet
Author: User
Tags tomcat

Original address:

Read a lot of information from the Internet, want to know how to integrate Apache and Tomcat, so that Apache httpd responsible for static content, let Tomcat responsible for dynamic content parts.

Reference article:


I tried it myself and recorded the process for future review.

1. Install Apache HTTP server, Tomcat, Tomcat Connector (JK Module) apache Httpd: Download Apache HTTP server from the Internet 2.2.15 installation Version (seemingly no install compression version). You can choose to install it as a system service or to start each time manually. I'm just testing, so I chose the latter, but the latter will listen to port 8080 by default, and be careful not to clash with Tomcat's default port 8080. This item can be modified later in the configuration file. Tomcat: You can choose to install the compact version (I use the 6.0.18 version), very convenient, can be registered as a system service. JK Module: Find binary download from, download current latest version 1.2.30 File Mod_, rename it to and place it in the modules directory under the Apache Http Server installation directory.

2. Create a new file

Refer to:

This can be placed in any directory, I put it directly in the Apache Http Server installation directory.

# indicates the installation path for Tomcat for the MOD_JK module
# Specify the JDK installation path for the MOD_JK module
Workers.java_home=c:/program files/java/jdk1.6.0_20

# Add a worker to the worker list

# Set individual parameters for Worker1

# work port, Tomcat's default connector listening port, you can view Tomcat in Server.xml with port= "8009"
# tomcat machine, if installed in a different machine than Apache needs to set the IP
# type of worker, allowable values are ajp13, AJP14, LB, status, etc. ajp13 is the preferred way to MOD_JK connect webserver and tomcat (i.e. use socket as communication channel)
# load Balancing Factor

Note: The name of the worker in Worker.list should be the Jkmount in the httpd.conf configuration file corresponding to the Apache Http Server (detailed later).

3. Modify the httpd.conf configuration file for Apache Http server

Modify the httpd.conf file under the Conf directory in the Apache Http Server installation directory:

# Load the MOD_JK module and note the path to the module file
LoadModule Jk_module modules/
# declaring the location of the file
Jkworkersfile "C:/Program Files/apache software Foundation/apache2.2/"
# declares the log file location for MOD_JK
Jklogfile "C:/Program Files/apache software Foundation/apache2.2/logs/mod_jk.log"
# Declare the log level of the MOD_JK (optional)
Jkloglevel Info
# Declare the timestamp format of the MOD_JK log (optional)
Jklogstampformat "[%a%b%d%h:%m:%s%Y]"

#/*.action and/*.jsp types of requests are assigned to Tomcat, and the remaining types have Apache Http server handling themselves
# Note the name of the worker in Worker.list in the file that follows the worker1 of Jkmount
Jkmount/*.action Worker1
Jkmount/*.jsp Worker1

4. Modify Directoryroot

Most of the articles on the Internet are only written to the end of the above, the dynamic content to one of the Tomcat step is completed, but the allocation of static content also need to set the httpd.conf file.

Find the line DocumentRoot "C:/Program Files/apache software Foundation/apache2.2/htdocs" and replace its value with the Web app's path:

DocumentRoot "D:/devsoft/apache-tomcat-6.0.18/webapps"

Find the <directory "C:/Program Files/apache software Foundation/apache2.2/htdocs" > This line and replace its value with the Web app's path:

<directory "D:/devsoft/apache-tomcat-6.0.18/webapps" >

At this point, the dynamic content and static content of the request allocation, is basically complete.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.