Apache-Tomcat的整合操作的英文介绍--用mod_jk2.so实现

Integrating Apache 2.0 with Tomcat 5.5 for Windows

Background
This document outlines the process for integrating the Apache web-server with the Tomcat JSP/Servlet container. This configuration allows you to use Apache for serving static web content such as pure HTML pages while using Tomcat for dynamic content such as JSP pages and servlets. This configuration allows you to independently configure the two environments offering improvements in performance and scalability. 

Prerequisites
Please refer to the following guide(s) and follow the instructions included within to install/configure the required software:
·         Getting Started with Apache for Windows
·         Getting Started with Tomcat for Windows
Download
1. Download the mod_jk2.so from jakarta-tomcat-connectors-jk2.0.4-win32-apache2.0.49.zip
2. Download the Tomcat 4.1 from http://www.eu.apache.org/dist/jakarta/tomcat-5/v5.5.2/bin/jakarta-tomcat-5.5.2.exe
3. Download the Apache 2.0 from http://www.eu.apache.org/dist/httpd/binaries/win32/apache_2.0.51-win32-x86-no_ssl.msi

Notes:
1.     The JK connector is now deprecated. Use the Coyote JK 2 connector noted above instead.
2. The version of mod_jk2.dll to download is dependent on the version of Apache that was installed (in this case Apache 2.0.43 was installed so the mod_jk2-2.0.43.dll is downloaded); it is not dependent on the version of Tomcat that was installed. Though noted for Apache 2.0.43 this connector will also work with Apache 2.0.50.

Installation
Configure Apache
1.     Copy  mod_jk2.so to the <apache-install-dir>/Apache2/modules directory (e.g. C:/Program Files/Apache Group/Apache2/modules)
2.     Edit the Apache server configuration file httpd.conf. This file can be found in the <apache-install-dir>/Apache2/conf directory or can be accessed from the Start menu under Start -> Programs -> Apache HTTP Server 2.0.45 -> Configure Apache Server -> Edit the Apache httpd.conf Configuration File. Find the LoadModule section of the configuration file and add the following line with the other LoadModule entries: 
                              LoadModule jk2_module modules/mod_jk2.so

3.     In the <apache-install-dir>/Apache2/logs directory (e.g. C:/Program Files/Apache Group/Apache2/logs) create three empty files: stdout.log, stderr.log, and jk2.shm; make sure they aren’t saved with a different suffix.
4.     In the <apache-install-dir>/Apache2/conf directory (e.g. C:/Program Files/Apache Group/Apache2/conf) create a new file called workers2.properties (make sure its not saved with an additional suffix), and type in the following lines (note: you may need to change the value of file to reflect your Apache installation):
If you are running Apache and Tomcat on the same machine then you would have the following workers2.properties:
[shm:]
file=C:/Program Files/Apache Group/Apache2/logs/jk2.shm
size=1000000
[channel.socket:localhost:8009]
port = 8009
host = 127.0.0.1
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
[uri:/jsp-examples/*]
[uri:/tomcat-docs/*]
worker=ajp13:localhost:8009
              
If you are running Apache and Tomcat on separate machines then you would have the following workers2.properties:
[shm:]
file=C:/Program Files/Apache Group/Apache2/logs/jk2.shm
size=1000000
[channel.socket:IPAddressOfTomcatMachine:8009]
port=8009
host=IPAddressOfTomcatMachine
[ajp13:IPAddressOfTomcatMachine:8009]
channel=channel.socket:IPAddressOfTomcatMachine:8009
[uri:/jsp-examples/*]
[uri:/tomcat-docs/*]
worker=ajp13:IPAddressOfTomcatMachine:8009
Where IPAddressOfTomcatMachine is the IP address of the machine on which Tomcat will be run (it can also be a machine name).
The last two lines in the workers2.properties file are used to configure the forwarding features of Apache. These lines tell Apache to contact Tomcat whenever the requested URL contains /jsp-examples or /tomcat-docs (these are the two web-apps deployed in Tomcat).
Instead of mapping the entire application to Tomcat, prefix or extension URI mappings can be defined so that Apache serves all static content and Tomcat serves all dynamic content. Please refer to the documentation link noted above for more details on this. 
In any event, you should configure URI mappings to cover any installed web-apps that you may have in your environment. The examples given here are for the Tomcat examples and the Tomcat documentation.
Configure Tomcat
Note: You don’t have to modified the configure, leave it as default,   just remind that start up Tomcat first, or you may check that
  <Connector port="8009" enableLookups="false" redirectPort="8443" debug="0" protocol="AJP/1.3" />
should not be committed in the %TOMCAT_HOME%/conf/server.xml.

Note: Once you have Apache and Tomcat configured to work together you will no longer be able to use them as Windows Services. This is because this integration requires that Tomcat be started before Apache and there is no guaranteed to the order in which Windows services are started. Therefore, another mechanism must be used that allows for the specifying the order in which processes are started. If Apache and/or Tomcat are configured as Windows Services you will need to reconfigure them to start manually instead of automatic.

Test
1.     If Tomcat is already running then stop it. Start Tomcat from the Start Menu or from a command prompt (if unsure how to do this, please refer to the installation guide for Tomcat).
2.     If Apache is already running then stop it. Start Apache from the Start Menu or from the command prompt (if unsure how to do this, please refer to the installation guide for Apache).
3.     Once both Tomcat and apache are running try the following URL’s to verify the integration:
a.      Open http://localhost:8080 in your browser – displays a Tomcat test page
b.      Open http://localhost in your browser – displays an Apache test page.
c.       Open http://localhost:8080/jsp-examples in your browser - displays the Tomcat examples directory listings (images, jsps, and servlets); the request is going directly to Tomcat.
d.      Open http://localhost/jsp-examples in your browser - displays the Tomcat examples directory listings again; except this time the request is going through Apache; which routes it to Tomcat.
Note: the above URLs that are missing port number 8080 (see b and d); means that the request is going to the Apache HTTP server; instead of going directly to the Tomcat Web server.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值