hanzou

 

linux下整合apache和tomcat

1,下载需要的软件(假设tomcat已经安装):
httpd-2.2.11.tar.gz
tomcat-connectors-1.2.28-src.tar.gz
2,安装apache:
tar zxf httpd-2.2.11.tar.gz
cd httpd-2.2.11
./configure --prefix=/usr/local/apache2 --enable-so(linux必须已经安装gcc才能通过)
make
make install
3,编译生成mod_jk:
tar zxf tomcat-connectors-1.2.28-src.tar.gz
cd tomcat-connectors-1.2.28-src/native
./configure --with-apxs=/usr/local/apache/bin/apxs
make
cp ./apache-2.0/mod_jk.so /usr/local/apache2/modules/
4,配置:
在/usr/local/apache2/conf/下面建立两个配置文件mod_jk.conf和workers.properties
vi mod_jk.conf:
JkWorkersFile /usr/local/apache2/conf/workers.properties
JkLogFile /usr/local/apache2/logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /*/servlet/* worker1
JkMount /*.jsp         worker1
JkMount /*.do          worker1
vi workers.properties:
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300
配置httpd.conf:
在DirectoryIndex中添加 index.jsp
增加关于加载mod_jk的语句:
LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache2/conf/mod_jk.conf

编辑Tomcat的配置文件server.xml,在HOST段中加入:
<Context path="" docBase="/usr/local/apache2/htdocs"
reloadable="true" crossContext="true"/>
到此为止apache和tomcat的整合已经配置完成了
应用时把静态相关的东西比如html,js,css,image放到apache的htdocs中,tomcat上保留jsp,class的东西,启动apache和tomcat就可以访问了。

btw,启动/关闭apache:/usr/local/apache2/apachectl start/stop



posted on 2009-06-01 09:44 hanzou 阅读(315) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿

随笔档案(13)

搜索

最新评论

阅读排行榜

评论排行榜