Apache2与Tomcat6整合

运行环境:Windows7
一、安装程序
1. 安装jdk-6u11(jdk-6u11-windows-i586-p.exe文件)
将其安装在D:\Program Files\Java\jdk1.6.0_11下
2. 安装Apache服务器 (httpd-2.2.17-win32-x86-no_ssl.msi)
运行Apache的自动安装包,安装Apache2.2.17到
D:\Program Files\Apache Software Foundation\Apache2.2目录下。
3. 安装Tomcat服务器 (japache-tomcat-6.0.24.exe)
运行Tomcat的自动安装包,安装
Tomcat 6.0到D:\Program Files\Apache Software Foundation\Tomcat 6.0目录下。
4. 安装mod_jk (mod_jk-1.2.30-httpd-2.2.3.so)
拷贝mod_jk-1.2.30-httpd-2.2.3.so文件到
D:\Program Files\Apache Software Foundation\Apache2.2\modules文件夹下。
下载地址:http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.30/
5. 准备工作目录和测试文件
在E:盘新建目录www,并创建一个基本的index.jsp文件,源码如下所示:

1.配置Apache服务器
编辑httpd.conf文件,在文件的最后添加如下内容: 

# Using mod_jk2.dll to redirect dynamic calls to Tomcat 
LoadModule jk_module "D:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_jk-1.2.30
-httpd-2.2.3.so"
JkWorkersFile "D:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/workers.properties" 
JkLogFile "D:/Program Files/Apache Software Foundation/Tomcat 6.0/logs/mod_jk2.log" 
JkLogLevel info 
JkMount /servlet/* ajp13 
JkMount /*.jsp ajp13 
Alias /web "E:/www/" 
<Directory "E:/www"> 
Options Indexes MultiViews 
AddOutputFilter Includes html 
AllowOverride None 
Order allow,deny 
Allow from all 
</Directory>

 

2.配置Tomcat服务器
1、建立workers.properties文件
在D:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/目录下新建文本文档并命名为
workers.properties,写入如下内容:

workers.tomcat_home=D:\Program Files\Apache Software Foundation\Tomcat 6.0
workers.java_home=D:\Program Files\Java\jdk1.6.0_11
ps=\ 
worker.list=ajp13 

worker.ajp13.port=8009 
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1

worker.loadbalancer.type=lb 
worker.loadbalancer.balanced_workers=ajp12, ajp13 
worker.inprocess.type=jni 
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)classes 
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)jaxp.jar 
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)parser.jar 
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)jasper.jar 
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)servlet.jar 
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)webserver.jar 
worker.inprocess.class_path=$(workers.java_home)$(ps)lib$(ps)tools.jar 
worker.inprocess.cmd_line=-config 
worker.inprocess.cmd_line=$(workers.tomcat_home)/conf/jni_server.xml 
worker.inprocess.cmd_line=-home 
worker.inprocess.cmd_line=$(workers.tomcat_home) 
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)jvm.dll
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)inprocess.stdout 
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)inprocess.stderr 
worker.inprocess.sysprops=tomcat.home=$(workers.tomcat_home)

 2、修改server.xml文件
在D:\Program Files\Apache Software Foundation\Tomcat 6.0\conf 目录下找到server.xml文件,用文本文档

打开后查找</HOST>。
在</HOST>的前一行加入如下内容:

<Context path="/web" docBase="E:/www" debug="0" reloadable="true" > </Context>

 3、修改jk2.properties文件
在D:\Program Files\Apache Software Foundation\Tomcat 6.0\conf 目录下找到(或者新建)jk2.properties文

件,用文档打开并删除所有内容。
将jk2.properties文件内容填写为以下内容:

## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE TOMCAT IS STOPED 
## WHEN YOU EDIT THE FILE. 
## COMMENTS WILL BE _LOST_ 
## DOCUMENTATION OF THE FORMAT IN JkMain javadoc. 
# Set the desired handler list 
handler.list=apr,request,channelJni 
# 
# Override the default port for the socketChannel 
# channelSocket.port=8019 
# Default: 
# channelUnix.file=${jkHome}/work/jk2.socket 
# Just to check if the the config is working 
# shm.file=${jkHome}/work/jk2.shm 
# In order to enable jni use any channelJni directive 
# channelJni.disabled = 0 
# And one of the following directives: 
# apr.jniModeSo=/opt/apache2/modules/mod_jk2.so 
# If set to inprocess the mod_jk2 will Register natives itself 
# This will enable the starting of the Tomcat from mod_jk2 
# apr.jniModeSo=inprocess 
#request.tomcatAuthentication=true 
request.tomcatAuthentication=false 

  

三、系统环境变量配置
右键我的电脑-属性-高级-环境变量,在系统变量中增加以下变量

JAVA_HOME = D:\Program Files\Java\jdk1.6.0_11
TOMCAT_HOME = D:\Program Files\Apache Software Foundation\Tomcat 6.0
CATALINA_HOME = D:\Program Files\Apache Software Foundation\Tomcat 6.0
PATH = %PATH%;%JAVA_HOME%\BIN
CLASSPATH = ;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tool.jar;%JAVA_HOME%\lib\NetComponents.jar;
%JAVA_HOME%\lib\mm.mysql-2.0.4-bin.jar
CLASSPATH = %CLASSPATH%;%TOMCAT_HOME%\common\classes;%TOMCAT_HOME%\common\lib;%TOMCAT_HOME%\common\lib\servlet-api.jar

以上配置完成后重新启动系统

四、运行测试程序
开始-运行D:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\startup.bat(启动Tomcat),再运行D:\Program Files\Apache Software Foundation\Apache2.2\bin\ApacheMonitor.exe(启动Apache)。
打开IE浏览器,分别输入如下地址:
http://127.0.0.1/web/index.jsp
http://127.0.0.1:8080/web/index.jsp
如果出现的页面相同,均出现:
Hello:greatwqs@msn.com..
说明配制成功,效果见附件!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值