LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2049|回复: 2

整合 Apache + Tomcat

 关闭 [复制链接]
发表于 2006-4-21 20:37:22 | 显示全部楼层 |阅读模式
1.下载jdk-1_5_0_06,httpd-2.0.55.tar.gz,apache-tomcat-5.5.16.tar.gz,jakarta-tomcat-connectors-1.2.15-src.tar.gz

2.编译apache
#./configure --prefix=/opt/apache --enable-modules=so;make;make install

3.解压tomcat,在/opt/tomcat/bin/startup.sh和shutdown.sh中添加环境变量JAVA_HOME

4.解压tomcat-connectors
#cd jk/native
#./configure --with-apxs=/opt/apache/bin/apxs;make;make install

5.建立 /opt/apache/conf/workers.properties,添加以下内容:

workers.tomcat_home=/opt/tomcat/
workers.java_home=$JAVA_HOME
ps=/
worker.list=default
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

6.在/opt/apache/conf/httpd.conf最后添加

LoadModule jk_module modules/mod_jk.so
<IfModule mod_jk.c>
         JKWorkersFile /opt/apache/conf/workers.properties
         JKLogFile /var/log/mod_jk.log
         JKLogLevel warn
         JKMount /*.jsp ajp13
</IfModule>

6.启动
#/opt/tomcat/bin/startup.sh
#/opt/apache/bin/apachectl start

测试的test.jsp放到/opt/tomcat/webapps/ROOT,用 http://localhost/test.jsp 看看

参考:http://www.freebsdchina.org/forum/topic_30435.html
-------------------------------------------------------------------------------------------------------------------

Apache 2.2.x  整合 tomcat

The AJP proxy is a new module based on the standard Http proxy it uses AJP instead of HTTP.
<Location /examples/>
   ProxyPass ajp://localhost:8009/examples/
</Location>

http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html
 楼主| 发表于 2006-4-21 20:37:43 | 显示全部楼层

整合resin与apache2

1.下载jdk-1_5_0_06,httpd-2.0.55.tar.gz,resin-3.0.18.tar.gz

2.编译apache
#./configure --prefix=/opt/apache --enable-modules=so;make;make install

3.把resin解压到/opt/resin,编译mod_caucho.so
./configure --with-apxs=/opt/apache/bin/apxs --with-apache=/usr/local/apache;make;make install

4.修改/opt/apache/conf/httpd.conf的最后为

LoadModule caucho_module /usr/local/apache/modules/mod_caucho.so
#ResinConfigHost localhost 6802
<IfModule mod_caucho.c>
ResinConfigServer localhost 6802
<Location /caucho-status>
SetHandler caucho-status
</Location>
</IfModule>

5.修改/opt/resin/conf/resin.conf
<cluster>
      <srun server-id="" host="本机的ip地址" port="6802"/>
</cluster>


6.根据自己的情况修改/opt/resin/bin/httpd.sh里环境变量JAVA_HOME和RESIN_HOME

7.启动
#/opt/resin/bin/httpd.sh &
#/opt/apache/bin/apachectl start
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-7-13 11:56:56 | 显示全部楼层

[zt]整合Apache Web Server + Tomcat

原文:http://www.freebsdchina.org/forum/topic_30435.html

本文虽然是FREEBSD的,但是后面配置文件是通用的,还可参考:

介绍了各种版本的apache和tomcat整合
http://www.apachetomcat.com/

1.建议大家检查 /etc/rc.conf,看看有没有开启Linux二进制兼容模式!
  linux_enable="YES"
2.安装之前,需要你安装JDK - Java Develop Kit
Tomcat 4.x.x 以下版本 - JDK 1.3.X ~ JDK1.4.X
Tomcat 5.0.x 版本 - JDK 1.4.X or upper
Tomcat 5.5.x 版本 - JDK 5.0
3.下面开始进行。首先,请针对所需要安装的ports进行cvsup !
(1)安装Apache Web Server
代码:
# cd /usr/ports/www/apache13/
# make
# make install
完成后,请在 /etc/rc.conf 加入如下内容:
代码:
apache_enable="YES"
(2)安装Apache Tomcat
代码:
# cd /usr/ports/www/jakarta-tomcat5/
# make
# make install
安装完成后,请确认是存在/usr/local/bin/tomcat50ctl!并确认server.xml是有开启AJP1.3的:
代码:
<Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
(3)配置一些环境变量
图简单可以把它们放在/etc/rc.conf中!
代码:
export JAVA_HOME=/usr/local/jdk1.5.0
export CATALINA_HOME=/usr/local/jakarta-tomcat5.0
export CLASSPATH=.JAVA_HOME/jre/lib/rt.jarJAVA_HOME/lib/dt.jarJAVA_HOME/lib/tools.jar
(4)阶段性测试
看看Tomcat是否正常:
代码:
# cd /usr/local/jakarta-tomcat5.0/bin/
# ./startup.sh
应该看到如下的内容,并请你用Web浏览器测试Tomcat!
代码:
Using CATALINA_BASE:   /usr/local/jakarta-tomcat5.0
Using CATALINA_HOME:   /usr/local/jakarta-tomcat5.0
Using CATALINA_TMPDIR:   /usr/local/jakarta-tomcat5.0/temp
Using JAVA_HOME:   /usr/local/jdk1.5.0
(5)开始进行整合Apache & Tomcat
首先安装mod_jk:
代码:
# cd /usr/ports/www/mod_jk
# make
# make install
完成后,请修改/usr/local/etc/apache/httpd.conf,找到下面2行,把行首的注释符号#去掉!
代码:
LoadModule jk_module  libexec/apache/mod_jk.so
AddModule  mod_jk.c
新增下面的配置内容:
代码:
Include /usr/local/etc/apache/mod_jk.conf
修改/usr/local/etc/apache/mod_jk.conf的内容:
代码:
<IfModule mod_jk.c>
JkWorkersFile /usr/local/etc/apache/workers.properties
JkLogFile  /var/log/mod_jk.log
JkLogLevel warn
JkMount /*.jsp default
JkMount /servlet/* default
JkMount /examples/* default
</IfModule>
接下来,需要修改/usr/local/etc/apache/workers.properties (注意2个文件中的default只是一个代号!):
代码:
workers.tomcat_home=/usr/local/jakarta-tomcat5.0
workers.java_home=$JAVA_HOME
ps=/
worker.list=default
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
好,到这里配置基本上完成了,接下来开始祈祷并运行吧!
代码:
# touch /var/log/mod_jk.log
# /usr/local/bin/tomcat50ctl start
# /usr/local/sbin/apachectl start
写一个测试的test.jsp放到/usr/local/jakarta-tomcat5.0/webapps/ROOT/,用 http://localhost/test.jsp 看看
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表