经过一番折腾,总算搞定了apache与tomcat的整合问题,操作如下:
安装jdk到c:\jdk
下载apache http://apache.te8.com/dist/httpd/binaries/win32/apache_2.0.47-win32-x86-no_ssl.msi
下载tomcat http://apache.te8.com/dist/jakarta/tomcat-5/v5.0.12-beta/bin/jakarta-tomcat-5.0.12.exe
下载apache tomcat 连接器 http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/v1.2.4/bin/win32/mod_jk_2.0.46.dll 最高版本,2.0.47的没有,不过这个也可同2.0.47工作。
安装tomcat到目录c:\tomcat,安装apache到c:\最后apache主目录为c:\apache2,放mod_jk到c:\apache2\modules\目录下
配置apache httpd.conf 使之自动支持中文改AddDefaultCharset ISO-8859-1 为AddDefaultCharset GB2312 在最后增加如下内容:
# Using mod_jk2.dll to redirect dynamic calls to Tomcat
LoadModule jk_module modules/mod_jk.dll
JkWorkersFile "C:/Tomcat/conf/workers.properties"
JkLogFile "C:/Tomcat/logs/mod_jk2.log"
JkLogLevel info
JkMount /servlet/* ajp13
JkMount /*.jsp ajp13
增加虚拟目录:
Alias /web "D:/www/"
<Directory "D:/www">
Options Indexes MultiViews
AddOutputFilter Includes html
AllowOverride None
Order allow,deny
Allow from all
</Directory>
在F:\Tomcat\conf目录下新建文件workers.properties内容如下
workers.tomcat_home=C:\Tomcat #让mod_jk模块知道Tomcat
workers.java_home=C:\jdk #让mod_jk模块知道j2sdk
ps=worker.list=ajp13 #模块版本,现有ajp14了,不要修改
worker.ajp13.port=8009 #工作端口,若没占用则不用修改
worker.ajp13.host=localhost #本机,若上面的Apache主机不为localhost,作相应修改
worker.ajp13.type=ajp13 #类型
worker.ajp13.lbfactor=1 #代理数,不用修改
tomcat的server.xml增加一行内容:
<Context path="/web" docBase="D:/www" debug="0" reloadable="true" > </Context>
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
# apr.jniModeSo=F:\Apache2\modules\mod_jk2-2.0.43.dll
# 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
完毕。
先启动tomcat后启动apache,运行http://localhost/web/test.jsp与运行http://localhost:8080/web/test.jsp结果相同即成功。