apache2.0+tomcat5整合文档
2005-12-08 08:53
381 查看
下面来简述一下,我配置的过程,准备工作如下: 关于apache2.X版与Tomcat5.X整合的技术文档,在网上找了两天,大部分都是指定使用apache2.08+tomcat5.0.16+mod_jk2.dll什么的,我用其它版本的怎样试也不行,无奈之余,就又到网上四处找tomcat5.0.16版,TOMCAT官方网站没有下载了,其实我是步入了一个误区,其实尽信书则不如无书,TOMCAT无论用哪个版本,高版本大部分都兼容低版本的功能.希望各位以后网上资料参考就好了,最主要是看开源的帮助文档才最重要,不过是E文的,慢慢看吧,带个金山词霸.^_^ 闲话少说,言归正传,下面介绍我的配置步骤吧! 前提准备工作及配置环境如下: 操作系统是,WINDOWS2K SERVICE版 jdk1.5(其实什么版本也无所谓了,1.4以上都行) TOMCAT5.0.19.exe文件,在TOMCAT官方网也没有下载了,我以前下载的,要的话,可以发邮件给我,(5.0版本都无所谓了) apache_2.0.49-win32-x86-no_ssl.msi apache服务器(这个apache版本,因apache我不太熟,限不限定版本号,没有测试过) 下载网址:http://archive.apache.org/dist/httpd/binaries/win32/
jakarta-tomcat-connectors-jk2.0.4-win32-apache2.0.49.zip(TOMCAT5与APACHE2 plus)//这个中间件在apache官方网有下载 下载网址:http://archive.apache.org/dist/tomcat/tomcat-connectors/jk2/binaries/win32/ 1. 安装并测试Apache和TomCat5.0; 注意事项: Apache默认端口为80,与IIS冲突,更改端口或关闭IIS, TomCat安装完后配置环境变量。 2. 开始整合; 首先,先把jakarta-tomcat-connectors-jk2.0.4-win32-apache2.0.49.zip解压后,从modules目录中取出来mod_jk2.so文件,复制到,apache安装根目录/apache2/modules/目录下.
其次,编辑配置文件。具体的配置文件有四个, 它们分别是:httpd.conf、jk2.properties、server.xml、workers2.properties。
我的配置如下:
a、 修改ApacheRoot/Apache2/conf/httpd.conf 文件 1>修改web 主目录,即将 DocumentRoot "D:/websrv/Apache2/htdocs" 改为自己的web主目录 eg: DocumentRoot "D:/test/jsptest" 2>修改web 主目录对应的目录,即将 <Directory "D:/websrv/Apache2/htdocs">改为 eg: <Directory "D:/test/jsptest" > 此目录块要与DocumentRoot的路径对应,块中的语法是对此块对应Web主目录的操作权限设置。 3>修改目录缺省的web文件,即将 DirectoryIndex index.html index.html.var 改为 eg: DirectoryIndex index.html index.html.var index.jsp 语法说明:当向Apache 发出请求时容器将顺次去找index.html,如果没有,将接着找index.htm,最后找index.jsp。 4>修改cgi-bin 所在目录,即将 ScriptAlias /cgi-bin/ "D:/websrv/Apache2/cgi-bin/"改为 ScriptAlias /cgi-bin/ "D:/test/jsptest/cgi-bin/" <Directory "D:/websrv/Apache2/cgi-bin"> 改为 <Directory "D:/test/jsptest/cgi-bin"> 如果程序中需要用到cgi时修改以上两处。 5>添加指定的虚拟目录(别名),及其对应目录的属性 #这是测试用的文件夹,能执行jsp 文件。 Alias /jmmis/ "D:/test/jsptest/jmmis/" <Directory "D:/test/jsptest/jmmis" > AllowOverride None Options IncludesNoExec AddOutputFilter Includes html AddHandler type-map var Order allow,deny Allow from all </Directory>
#在web主目录jsptest中添加了jmmis目录 语法说明: Alias /web程序别名/ "程序根目录/" ##别忘啦最后有“/” <Directory "程序根目录" > AllowOverride None Options IncludesNoExec AddOutputFilter Includes html 对此程序的具体操作权限设置 AddHandler type-map var Order allow,deny Allow from all </Directory> 注意: 程序根目录必须和%Tomcat5%/conf/server.xml中配置的虚拟目录相吻合。 6>添加默认字符集的设置 AddDefaultCharset GB2312 7>在文件最后添加如下内容,以加载jk2 模块 <IfModule !mod_jk2.c> LoadModule jk2_module modules/mod_jk2.so </IfModule>
以上都是配置httpd.conf Apache服务器的东西!
接下来配JK2了 JK2指定一个worker2.properties文件 存放路径为就是SERVERROOT/conf 这里的serverroot 是apache的安装目录 原JK2帮助文档显示如下所示 workers2.properties is used on the webserver side. For the Apache servers the default path is in the ServerRoot/conf directory.
worker2.properties文件如下:
[shm] info=Scoreboard. Requried for reconfiguration and status with multiprocess servers. file=anon
# Defines a load balancer named lb. Use even if you only have one machine. [lb:lb]
# Example socket channel, override port and host. [channel.socket:localhost:8019] port=8019 host=127.0.0.1
# define the worker [ajp13:localhost:8019] channel=channel.socket:localhost:8019 group=lb
# Map the Tomcat examples webapp to the Web server uri space [uri:/*.jsp] group=lb [uri:/Servlet/*] group=lb [status:] info=Status worker, displays runtime information
[uri:/jkstatus/*] info=The Tomcat /jkstatus handler group=status:
接着修改JK2.properties文件,默认不用作什么修改, TOMCAT5/conf的jk2.properties文件不需太多修改, jk2的属性文件如下
## 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.NativeSo=/home1/jakarta/jakarta-tomcat-connectors/jk/build/jk2/apache2/jkjni.so
apr.jniModeSo=/ApacheRoot/apache2/modules/mod_jk2.so #apr.jniModeSo=C:/Apache/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 #Shared memory directive shm.file=C:/Apache/Apache2/logs/jk2.shm
修改TOMCAT下/conf目录下的server.xml文件
保持通信管道端口号一致 与worker2.properties文件中, # define the worker [ajp13:localhost:8019] channel=channel.socket:localhost:8019 所定义的8019一致 <Connector port="8019" enableLookups="true" redirectPort="8443" debug="0" protocol="AJP/1.3" />
同时在</host>位置增加虚拟目录
<Context path="/jmmis" docBase="D:/test/jsptest/jmmis" debug="0" reloadable="true" crossContext="true"></Context>
这里也许会报警告信息,修改 TOMCAT/CONF/下的server-minimal.xml的文件,把默认的8009修改为8019
以上修改完成后,重启APACHE TOMCAT就大功告成了!
相关文章推荐
- apache2.0+tomcat5整合文档
- linux下 apache2.0+tomcat5如何整合
- apache2.2.4 安装编译参数以及同tomcat5,php5的整合
- 基于WPF系统框架设计(5)-Ribbon整合Avalondock 2.0实现多文档界面设计(二)
- Apache HTTP服务器 2.0版本文档
- Apache 2.0 中文文档[Directory, Location and Files段]
- 整合Oracle 10g、Apache 2.0、Php 5
- 基于WPF系统框架设计(4)-Ribbon整合Avalondock 2.0实现多文档界面设计(一)
- Apache HTTP服务器 2.0版本文档
- 整合Oracle 10g、Apache 2.0、PHP 5
- 整合tomcat5与apache2
- FC5 下tomcat5与Apache整合
- 整合Oracle 10g、Apache 2.0、Php 5
- 整合apache 2.2.4 + Tomcat5 总结
- Ribbon整合Avalondock 2.0实现多文档界面设计(一)
- Apache2.0官方文档(中文版,超强)
- 在windows 2000,XP 下通过mod_jk2.so整合Tomcat5.0 和 Apache2.0
- 整合apache 2.2.4 + Tomcat5 总结
- windwos下整合apache2.2+tomcat5