整合 RH3 + TOMCAT5 + APACHE2 + jk2
注: 本文主要是拷贝www.chinanuix.net 中国UNIX社区 "最为完美的Tomcat+apache+php+jk2配置 (04/01/12更新)" 一文(http://www.chinaunix.net/jh/13/236685.html), 但或许是版本等原因,按原文配置完后并不能整合成功,又参考了一些讨论组的内容,终于尝试成功. 现完整贴出来, 希望对和我一样的初学者有所帮助, 必须说明的是, 主要是原作者的劳动, 在此向feiyi表示感谢.
运行环境: RedHat Enterprise 3.0
一. 有关说明
本文的目的是在RH3环境下用JK2整合Apache 和 Tomcat, 不涉及虚拟主机或PHP等. 下面一些步骤或许不是必需的, 请高手指正.
版本号:
Apache: 2.0.49
Tomcat: 5.0.19
jk2: 2.0.4
j2sdk: 1.4.2.04
下载文件: httpd-2.0.49.tar.gz
jakarta-tomcat-5.0.19.tar.gz
jakarta-tomcat-connectors-jk2-src-current.tar.gz
j2sdk-1_4_2_04-linux-i586.bin
安装位置:
Apache -> /usr/local/httpd-2.0.49
Tomcat -> /usr/local/jakarta-tomcat-5.0.19
j2sdk -> /usr/local/j2sdk1.4.2_04
jk2 -> /usr/local/jakarta-tomcat-connectors-jk2-2.0.4-src
建立软链接:
ln -s /usr/local/jakarta-tomcat-5.0.19 /usr/local/tomcat
ln -s /usr/local/httpd-2.0.49 /usr/local/apache
ln -s /usr/local/j2sdk1.4.2_04 /usr/local/jdk
有关配置文件的位置:
httpd.conf -> /usr/local/apache/conf/httpd.conf
workers2.properties -> /usr/local/apache/conf/workers2.properties
server.xml -> /usr/local/tomcat/conf/server.xml
jk2.properties -> /usr/local/tomcat/conf/jk2.properties
二. 安装步骤
JDK: rpm -ivh j2sdk-1_4_2_03-linux-i586.rpm
Apache: tar xvfz httpd-2.0.49.tar.gz
cd httpd-2.0.47
./configure --prefix=/usr/local/apache --enable-so
make
make install
(注: 安装RH3时, 并没选择安装Web服务)
Tomcat: tar xvfz jakarta-tomcat-5.0.19.tar.gz
编辑文件 /usr/local/tomcat/bin/catalina.sh
在注释行后插入这几行:
JAVA_HOME=/usr/local/jdk/
CATALINA_HOME="/usr/local/tomcat/"
JAVA_OPTS="-Xms256m -Xmx256m"
增加用户和组:
groupadd tomcat
useradd -g tomcat -c "Tomcat User" -d /usr/local/tomcat tomcat
chown -R tomcat:tomcat /usr/local/tomcat
chown -R tomcat:tomcat /usr/local/jakarta-tomcat-5.0.19
mkdir /usr/local/tomcat/webapps/mylog
JK2: tar xvfz jakarta-tomcat-connectors-jk2-src-current.tar.gz
cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2
chmod 755 buildconf.sh
./buildconf.sh
./configure --with-apxs2=/usr/local/apache/bin/apxs \
----with-apr-lib=/usr/local/apache/lib \
--with-tomcat-41=/usr/local/tomcat \
--with-java-home=/usr/local/jdk \
--with-jni
make
libtool --finish /usr/local/apache/httpd/modules
cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/build/jk2/apache2
cp mod_jk2.so /usr/local/apache/modules/
cp libjkjni.so /usr/local/apache/modules/
cd /usr/local/tomcat/logs
touch jk2.shm
usermod -G apache,tomcat apache
启动时运行,编辑文件:/etc/rc.d/rc.local 增加下面两行:
su - tomcat -c /usr/local/tomcat/bin/startup.sh
/usr/local/apache/bin/apachectl start
三. 修改配置文件, 配置文件如不存在, 就创建.
httpd.conf:
注释掉AddDefaultCharset 这行
增加: LoadModule jk2_module modules/mod_jk2.so
workers2.properties: 如下
# only at beginnin. In production uncomment it out
[logger.apache2]
level=DEBUG
[shm]
file=/usr/local/apache/logs/shm.file
size=1048576
# Example socket channel, override port and host.
[channel.socket:localhost:8009]
info=Ajp13 forwarding over socket
tomcatId=localhost:8009
# define the workUntitled 1er
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
[uri:/jsp-examples/*]
info=Map the jsp-examples webapp
worker=ajp13:localhost:8009
[uri:/servlets-examples/*]
info=Map the servlets-examples webapp
worker=ajp13:localhost:8009
jk2.properties: 如下
## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE TOMCAT IS STOPED
## WHEN YOU EDIT THE FILE.
## COMMENTS WILL BE _LOST_
## DOCUMENTATION OF THE FORMAT IN JkMain javadoc.
# Set the desired handler list
# handler.list=apr,request,channelJni
handler.list=channelSocket,request
#
# Override the default port for the socketChannel
# channelSocket.port=8019
channelSocket.port=8009
# Default:
# channelUnix.file=${jkHome}/work/jk2.socket
# Just to check if the the config is working
# shm.file=${jkHome}/work/jk2.shm
# In order to enable jni use any channelJni directive
# channelJni.disabled = 0
# And one of the following directives:
# apr.jniModeSo=/opt/apache2/modules/mod_jk2.so
# If set to inprocess the mod_jk2 will Register natives itself
# This will enable the starting of the Tomcat from mod_jk2
# apr.jniModeSo=inprocess
server.xml: 如下
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<Service name="Catalina">
<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" />
<!-- Define the top level container in our container hierarchy -->
<Engine name="Catalina" defaultHost="localhost" debug="0">
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<!-- Because this Realm is here, an instance will be shared globally -->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase"/>
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<!-- Tomcat Root Context -->
<!--
<Context path="" docBase="ROOT" debug="0">
-->
</Host>
<Host name="www.yourname.com" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="mylog_log." suffix=".txt"
timestamp="true"/>
<Context path="" docBase="mylog" debug="0" />
</Host>
</Engine>
</Service>
</Server>
分享到:
相关推荐
Apache2.4+Tomcat8.0集群安装--测试项目。集群配置地址为:
apache+tomcat的连接器。 整合Tomcat5.0和Apache2.0的连接器、中间件。
本文档提供了一套从零开始整合Apache2.0.48与Tomcat5.0.16的详细步骤,适用于学校系统平台开发竞赛等场景。通过图文并茂的方式,本教程旨在帮助读者快速掌握Apache与Tomcat的集成过程。 #### 二、Apache与Tomcat...
软件环境:Window server 2003+ IIS6.0 + Tomcat6.0 + JK2 整了大半天,不过直得整合的好处就不说了 1.导入注册表 iis+tomcat.reg 文件说明 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\...
Apache2.2.x + Tomcat6.x + jk2.x 集群配置教程 在互联网服务中,为了提供高可用性和负载均衡,通常会采用集群技术。Apache HTTP Server(通常简称为Apache)与Tomcat的结合是常见的Web服务器与应用服务器组合。...
- 下载 `mod_jk2-2.0.43.dll` 文件,并将其放置在 `D:\MyWebApps\Apache2.0.44\Apache2\modules` 目录。 - 修改 `D:\MyWebApps\Apache2.0.44\Apache2\conf\httpd.conf` 文件,在最后一行添加以下内容: ```apache ...
"workersFile"="C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\conf\\workers2.properties" "logLevel"="DEBUG" 2.Copy 文件 isapi_redirector2.dll jk2.properties workers2.properties 到tomcat...
### RedHat AS4 下 Apache2 + MySQL + PHP + Tomcat 整合及虚拟主机配置 #### 软件概述与安装准备 根据给定文件,本文档主要介绍如何在 RedHat AS4 操作系统上安装并配置 Apache2、MySQL、PHP 和 Tomcat,以及如何...
4. Apache Tomcat连接器: `jakarta-tomcat-connectors-jk2-2.0.4-src-current.tar.gz`,这个连接器允许Apache和Tomcat之间通信,实现负载均衡和会话持久性。可以从Apache Jakarta Tomcat Connectors项目获取。 5. ...
- 需要Tomcat Connector(JK2)来连接Apache和Tomcat,这里使用的是jk-1.2.30版本,需要与Apache版本相匹配。 3. **Tomcat Connector的安装**: - 将下载的JK2模块(mod_jk2.so)拷贝到Apache的modules目录下。 ...
2. **配置Apache和Tomcat** - 分别配置Apache和Tomcat的监听端口,如Apache监听80,Tomcat监听8080。 - 将连接器`mod_jk2.so`复制到Apache的`modules`目录。 3. **编辑Apache配置文件** 修改Apache的`httpd.conf...
4. "jakarta-tomcat-connectors-jk2.0.4-win32-IIS.zip":这是Apache Tomcat的JK2模块的zip包,用于在IIS和Tomcat之间建立连接。JK2是mod_jk的一个替代品,提供了一种更现代的、基于服务的体系结构,便于管理和配置...
【Apache+Tomcat 集群与负载均衡及Session绑定】是将多个Apache和Tomcat服务器配置成一个集群,以实现更高的服务可扩展性和可用性。集群的基本思想是通过将工作负载分散到多个服务器,避免单点故障,提高系统的整体...
### Apache+Tomcat集群与负载均衡配置详解 #### 一、环境说明 为了实现Apache与Tomcat集群的负载均衡,我们需要准备以下环境: 1. **服务器配置**:四台服务器,其中一台安装Apache,三台安装Tomcat。 - Apache...
9. Apache与Tomcat整合(JK插件配置) 首先,安装Apache服务器。通过tar命令解压httpd-2.2.9.tar.gz文件,并进入到解压目录,使用./configure命令进行配置,指定安装路径等,然后使用make和make install命令完成...
**整合Apache2.0与Tomcat5.0的步骤** 在Windows 2000或XP环境下,将...以上就是通过`mod_jk2.so`在Windows 2000或XP下整合Apache2.0和Tomcat5.0的详细过程。正确配置后,你可以享受到更高效的Web应用部署和管理。
**Apache和Tomcat整合的意义:** Apache因其高效、稳定和安全的特点,成为许多网站首选的Web服务器。然而,对于处理动态内容,如JSP和Servlet,Apache的能力相对较弱。而Tomcat作为一个轻量级的应用服务器,专门用于...