安装 Apache 2 和 Tomcat 5.5
2007-10-21 18:10
471 查看
安装 Apache 2 和 Tomcat 5.5
etony C.F.AN etony@tom.com
v0.0.1, 2006-6-1 本文档主要讲述在 Debian/testing 平台上如何简单的将Tomcat5.5和Apache2整合到一起. 1. 声明
版本信息:本文档的最新版本将张贴于: LinuxSir.Org论坛Debian 发行版讨论区;也可以从
http://debian.linuxsir.org/获取.反馈:所有评论, 错误报告, 其他信息以及批评, 请邮寄到
etony@tom.com;或在LinuxSir.Org论坛
Debian发行版讨论区张贴.版权信息:本文档的版权
(c)2006-2007归
etony C.F.AN所有.转载请注明源自
http://debian.linuxsir.org/.
2. 配置 JAVA 环境
操作步骤, 请参阅:安装Java环境
3. 配置 tomcat5.5
tomcat4太古老的一个版本了, 这里我们选择
tomcat5.5作为配置环境.当前
tomcat5.5版本为
5.5.17. 由于
tomcat5.5的更新速度很快, 我选择从
tomcat的官方网站下载.
$ wget http://apache.justdn.org/tomcat/tomcat-5/v5.5.17/bin/apache-tomcat-5.5.17.tar.gz将其解压到工作目录, 比如
# tar zxvf apache-tomcat-5.5.17.tar.gz -C /opt/配置环境变量
# export CATALINA_HOME=tomcat_install_path //比如这里应该是 /opt/apache-tomcat-5.5.17/你可以将其加入启动脚本中,比如
.bashrc. 然后, 运行
tomcat, 检查配置情况:
# tomcat_intall_path/bin/startup.sh // 这里是/opt/tomcat5.5//bin/startup.sh如果抛出错误, 根据错误检查自己的配置.
4. 获取 JK 模块
可以通过apt-get获取
JK模块或直接从官方网站获取编译好的二进制模块, 但是编译JK一点也不麻烦, 这里我选择编译生成
JK模块, 这有背
Debian的方法 ;) 下载JK模块的源代码JK的当前版本是 1.2.15, 运行下边的命令获取源代码:
$ wget http://www.apache.org/dist/tomcat/tomcat-connectors/jk/source/jk-1.2.15/jakarta-tomcat-connectors-1.2.15-src.tar.gz解压到临时目录:
# tar zxvf jakarta-tomcat-connectors-1.2.15-src.tar.gz -C /tmp/配置编译环境安装编译
JK所需要的软件包:
#aptitude update#aptitude install ibtool autoconf gcc apache2-prefork-dev g++编译 JK 模块在
JK的解压目录下运行:
#cd /tmp/jakarta-tomcat-connectors-1.2.15-src/jk/native#./configure --with-apxs=/usr/bin/apxs2or#./configure --with-apache=/etc/apache2#make详细的编译说明, 请参阅:
Jakarta Tomcat Connector: Installation for Apache 2.x将生成的
JK模块
JK复制到
/usr/lib/apache2/modules/
#cp ./apache-2.0/mod_jk.so /usr/lib/apache2/modules/
5. 创建配置文件
/etc/apache2/conf.d/mod_jk.conf# 指出mod_jk模块工作所需要的工作文件workers.properties的位置JkWorkersFile /etc/apache2/workers.properties# Where to put jk logsJkLogFile /var/log/apache2/mod_jk.log# Set the jk log level [debug/error/info]JkLogLevel info# Select the log formatJkLogStampFormat "[%a %b %d %H:%M:%S %Y]"# JkOptions indicate to send SSL KEY SIZE,JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories# JkRequestLogFormat set the request formatJkRequestLogFormat "%w %V %T"# 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理JkMount /servlet/* worker1JkMount /*.jsp worker1/etc/apache2/mods-available/jk.load
LoadModule jk_module modules/mod_jk.soInclude /etc/apache2/conf.d/mod_jk.conf并创建符号链接到mods-enabled/etc/apache2/workers.properties一个workers.properties例子:
# Define some propertiesworkers.apache_log=/var/log/httpd/workers.tomcat_home=/var/tomcat3workers.java_home=/opt/IBMJava2-131/ps=/# Define 4 workers, 3 real workers using ajp12, ajp13, jni, the last one being a loadbalancing workerworker.list=worker1, worker2, worker3, worker4# Set properties for worker1 (ajp12)worker.worker1.type=ajp12worker.worker1.host=locahostworker.worker1.port=8007worker.worker1.lbfactor=1# Set properties for worker2 (ajp13)worker.worker2.type=ajp13worker.worker2.host=locahostworker.worker2.port=8009worker.worker2.lbfactor=1worker.worker2.cachesize=10worker.worker2.cache_timeout=600worker.worker2.socket_keepalive=1worker.worker2.socket_timeout=60# Set properties for worker3 (jni)worker.worker3.type=jni# Set worker3 bridge type, here Tomcat 3.3worker.worker3.bridge=tomcat33# Set worker3 classpathworker.worker3.class_path=$(workers.tomcat_home)$(ps)classesworker.worker3.class_path=$(workers.tomcat_home)$(ps)lib$(ps)tomcat.jar# Set worker3 tomcat command lineworker.worker3.cmd_line=-homeworker.worker3.cmd_line=$(workers.tomcat_home)# Set worker3 Tomcat/JVM settingsworker.worker3.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)libjvm.soworker.worker3.stdout=$(workers.apache_log)$(ps)inprocess.stdoutworker.worker3.stderr=$(workers.apache_log)$(ps)inprocess.stderrworker.worker3.sysprops=tomcat.home=$(workers.tomcat_home)# Set properties for worker4 (lb) which use worker1 and worker2worker.worker4.balance_workers=worker1,worker2或直接使用
# Defining a worker named worker1 and of type ajp13worker.list=worker1# Set properties for worker1worker.worker1.type=ajp13worker.worker1.host=localhostworker.worker1.port=8009worker.worker1.lbfactor=50worker.worker1.cachesize=10worker.worker1.cache_timeout=600worker.worker1.socket_keepalive=1worker.worker1.socket_timeout=300
6. 创建虚拟站点
创建虚拟站点配置文件/etc/apache2/sites-available/并创建符号链接到目录
/etc/apache2/sites-enabled/最后编辑Tomcat的配置文件, 将其根目录指向所创建站点的根目录。
7. 测试
创建一个简单的jsp文件,比如<%@page contentType="text/html"%><%@page pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>JSP Test Page</title></head><body><h1>JSP Test Page</h1><%= new java.util.Date() %></body></html>置于根目录下,然后通过浏览器访问!
8. 参考文档
Jakarta Tomcat Connector: Installation for Apache 2.x
Jakarta Tomcat Connector: Workers HowTo
Linux下Apache与Tomcat整合的简单方法
相关文章推荐
- jdk1.5+apache-tomcat-5.5安装心得
- apache2.2.x(x>=3)安装配置及与tomcat5.5整合
- 安装Apache2.2.9,JK1.2,TOMCAT5.5集成作负载均衡
- Web 服务器 之 安装 Apache 2 和 Tomcat 5.5
- 安装 Apache 2 和 Tomcat 5.5
- Centos5.5整合Apache和Tomcat 之一安装Apache
- Centos5.5整合Apache和Tomcat 之二安装Tomcat
- FreeBSD 最小化安装 +diablo-jdk +Apache 与 Tomcat 整合!
- tomcat 5.0 + apache 2.0 完全安装步骤详解
- StartSSL 免费证书申请步骤以及Tomcat和Apache下的安装
- Ubuntu 16.10 安装 Apache, MySQL, PHP7, Tomcat, PhpMyAdmin
- windows+php5.5+apache2.4+tomcat+mod_jk配置
- 燃烧的远征java(二)-开发环境:tomcat 5.5 的The Apache Tomcat Native library which allows optimal performance 的解决
- 安装 tomcat 5.5 的注意事项
- (转)在Mac OS X中安装配置Apache + PHP + MySQL +Tomcat
- apache+tomcat安装配置
- windows安装PHP5.5+Apache2.4+Mysql5.5
- 我的centos上安装 jdk+apache+tomcat+tomcatconnector+myql 安装道路
- CentOS 5.5使用yum安装Apache+PHP+MySQL
- Centos下Tomcat 安装Apache Portable Runtime