linux下 apache2.0+tomcat5如何整合

1.jdk1.4以上,tomcat5.0以上

2.apache的下载地方http://archive.apache.org/dist/httpd/binaries/linux/

3.结合中间件http://archive.apache.org/dist/tomcat/tomcat-connectors/jk2/binaries/

4. 安装并测试Apache和TomCat5.0;
注意事项: Apache默认端口为80,tomcat用与冲突,更改端口。

5.把中间件的module中的mod_jk2.so文件,复制到,apache安装根目录/backup/apache2/modules/目录下

6.其次,编辑配置文件。具体的配置文件有四个,
它们分别是:httpd.conf、jk2.properties、server.xml、workers2.properties

a.修改/backup/apache2/conf/httpd.conf 文件

1>修改web 主目录,即将DocumentRoot "/backup/Apache2/htdocs" 改为自己的web主目录
eg: DocumentRoot "/tomcat5019/webapps/ROOT"
2>修改web 主目录对应的目录,即将<Directory "/backup/Apache2/htdocs">改为
eg: <Directory "/tomcat5019/webapps/ROOT" >此目录块要与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/ "/backup/Apache2/cgi-bin/"改为ScriptAlias /cgi-bin/
"/tomcat5019/webapps/ROOT/cgi-bin/"<Directory "/backup/Apache2/cgi-bin"> 改为<Directory "/tomcat5019/webapps/ROOT/cgi-bin">
如果程序中需要用到cgi时修改以上两处。
5>添加指定的虚拟目录(别名),及其对应目录的属性#这是测试用的文件夹,能执行jsp 文件。
Alias /jmmis/ "/tomcat5019/webapps/ROOT/jmmis/"<Directory
"/tomcat5019/webapps/ROOT/jmmis" >AllowOverride NoneOptions IncludesNoExecAddOutputFilter Includes htmlAddHandler type-map varOrder allow,denyAllow from all</Directory>
6>添加默认字符集的设置 AddDefaultCharset GB2312
7>在文件最后添加如下内容,以加载jk2 模块
<IfModule !mod_jk2.c>
LoadModule jk2_module modules/mod_jk2.so
</IfModule>
以上都是配置httpd.conf Apache服务器的东西!
8)接下来配JK2了JK2指定一个workers2.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.
workers2.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:8009]
port=8009
host=127.0.0.1
# define the worker
ajp13:localhost:8009]
channel=channel.socket:localhost:8009
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=8009
# 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=/backup/apache2/modules/mod_jk2.so
#apr.jniModeSo=/backup/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=/backup/Apache2/logs/jk2.shm
修改TOMCAT下/conf目录下的server.xml文件
保持通信管道端口号一致与worker2.properties文件中,
# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009所定义的8009一致
<Connector port="8009"
enableLookups="true" redirectPort="8443" debug="0"
protocol="AJP/1.3" />
同时在</host>位置增加虚拟目录
<Context path="/jmmis" docBase="/tomcat5019/webapps/ROOT" debug="0" reloadable="true"crossContext="true"></Context>

以上修改完成后,重启APACHE TOMCAT,OK, ^-^


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值