linux Apache和tomcat 完美整合

在网上找了许多资料,却没有一个完整的整全方法,现将成果和大家共同分享!

一. 准备

httpd-2.2.4.tar.gz 

tomcat-connectors-1.2.25-src.tar.gz

apache-tomcat-5.5.23.tar.gz

二.分别安装apache和tomcat

# tar xzvf httpd-2.2.4.tar.gz 
# cd httpd-2.2.4 

#./configure --prefix=/usr/local/apache /
--with-mpm=worker /
--enable-module=so /
--enable-modules=all /
--enable-mods-shared=all /
--enable-ssl=shared /
--enable-deflate=shared / # make # make install
   
   # cp apache-tomcat-5.5.23.tar.gz /usr/local/

# cd /usr/local/

# tar xzvf apache-tomcat-5.5.23.tar.gz
三、 编译生成mod_jk
# tar xzvf tomcat-connectors-1.2.25-src.tar.gz

# cd tomcat-connectors-1.2.25-src/native 

# ./configure --with-apxs=/usr/local/apache/bin/apxs 

# make 

# cp ./apache-2.0/mod_jk.so /usr/local/apache/modules/
四、配置
   在/usr/local/apache/conf/下建两个配置文件mod_jk.conf和workers.properties。
   
   mod_jk.conf内容:
 
JkWorkersFile /usr/local/apache/conf/workers.properties 

# Where to put jk logs 

JkLogFile /usr/local/apache/logs/mod_jk.log 

# Set the jk log level [debug/error/info] 

JkLogLevel error 

# Select the log format 

JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" 

# JkOptions indicate to send SSL KEY SIZE, 

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories 

# JkRequestLogFormat set the request format 

JkRequestLogFormat "%w %V %T" 

# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理 

JkMount /servlet/* wt-server 

JkMount /*.jsp wt-server 

workers.properties内容:
# Defining a worker named worker1 and of type ajp13 

worker.list=wt-server 

# Set properties for worker1 

worker.wt-server.type=ajp13 

worker.wt-server.host=localhost 

worker.lb-server.port=8009 

worker.wt-server.lbfactor=50 

worker.wt-server.cachesize=10 

worker.wt-server.cache_timeout=600 

worker.wt-server.socket_keepalive=1 

worker.wt-server.socket_timeout=300
 
再修改/usr/local/apache/conf/httpd.conf增加mod_jk的配置:
LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache/conf/mod_jk.conf
 
最后分别启动apache和tomcat
/usr/local/apache/bin/httpd &
/usr/local/apache-tomcat-5.5.23/bin/startup.sh &
 
这时在/usr/local/apache-tomcat-5.5.23/webapps/ROOT目录下加一index.jsp页面
,可通过80端口访问到index.jsp了,
比如:在同网另一台windows机上打开IE输入http://192.168.1.2/index.jsp
即可成功访问!
 
 
 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值