apache+tomcat整合之路

来源:互联网 发布:uml建模软件 编辑:程序博客网 时间:2024/05/01 03:51


1.下载apache、tomcat、jakarta-tomcat-connectors
http://httpd.apache.org/download.cgi
http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi
http://apache.justdn.org/jakarta/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz

2.编译安装apache 2.0.53  
# ./configure --prefix=/usr/local/apache   #安装apache到/usr/local/apache目录
# make
# make install

3.解包安装tomcat 5.0.28

tar -zxvf jakarta-tomcat-5.0.28.tar.gz -C /opt/tomcat28

4.编译安装Tomcat与Apache的整合器(jakarta-tomcat-connectors Ver.2.0.4)

(1)解压缩下载的包至/backup下。
(2)进入目录
#cd /backup/jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2
(3)编译安装
#./configure --with-apxs2=/usr/local/apache/bin/apxs
#make
#cd ../build/jk2/apache2
#/usr/local/apache/bin/apxs -n jk2 -i mod_jk2.so

(4)编辑Apache配置文件/usr/local/apache/conf/httpd.conf
在LoadModule段加入如下一行:
代码:
LoadModule jk2_module modules/mod_jk2.so

(5)在/usr/local/apache/conf/目录下编辑保存一个名为workers2.properties的文本文件,内容为:
代码:
[logger]
level=ERROR

[config:]
file=/usr/local/apache/conf/workers2.properties
debug=0
debugEnv=0

# Alternate file logger
[logger.file]
#level=DEBUG
level=ERROR
file=/var/log/httpd/jk2.log

[shm:]
info=Scoreboard. Required for reconfiguration and status with multiprocess servers
file=/var/log/httpd/jk2.shm
size=1048576
debug=0
disabled=0

[channel.socket:localhost:8009]
info=Ajp13 forwarding over socket
debug=0
tomcatId=localhost:8009
keepalive=1

[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
debug=0

[status:]
info=Status worker, displays runtime informations

[uri:/jkstatus/*]
info=Display status information and checks the config file for changes.
worker=ajp13:localhost:8009

[uri:/*.jsp]
worker=ajp13:localhost:8009
context=/

(6)修改/opt/tomcatapache/conf/server.xml,在
      <Host name="localhost" debug="0" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">   #在214行
下方加入这行:
代码:
<Context path="" docBase="/usr/local/apache/htdocs" debug="0" reloadable="true" crossContext="true"/>


保存退出。
(7)测试
A)方法一:Firefox地址栏输入http://localhost/examples/,看到JSP Samples及其两列图标链接了吧。
B)方法二:在/usr/local/apache/htdocs下编辑一test.jsp文件,内容为以下五行:
代码:
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%
out.print("<font color=red>This is JSP's test page!</font><br><br>");
%>
Hello! The time is now <%= new java.util.Date() %>

再在Firefox地址栏输入http://localhost/test.jsp,有输出下面两行文字吗?
 This is JSP's test page!

Hello! The time is now Fri Apr 15 15:07:09 CST 2005

OK,所有的工作就告一段落了,大功告成!

参考:http://www.linuxfans.org/nuke/modules.php?name=Forums&file=viewtopic&t=107525&highlight=

原创粉丝点击