apache|问题配置目的:
将apache作为两个tomcat server的前端,负责转发client request和server reponse。
apache地址:10.194.0.131
tomcat server地址:10.11.1.29、10.11.1.2
配置步骤如下:
一、下载新版本的Apache 2.0.54和Tomcat Connector 1.2.14.1源代码,编译安装Apache和Connector:
1.在Apache的源代码目录中运行BuildConf、Configure --prefix=/usr/local/Apache2.0.54、make、make install,将Apache安装到/usr/local/Apache2.0.54目录中。
2.在Connector源代码目录的jk/native/运行BuildConf、Configure --with-apxs=/usr/local/Apache2.0.54/bin/apxs、make、make install,将mod_jk.so安装到/usr/local/Apache2.0.54/modules目录。
二、配置apache:
1.配置workers属性文件:在apache的conf目录中建立workers.properties文件,内容如下:
ps=/worker.list=worker1,jvm1worker.worker1.port=8009worker.worker1.host=10.11.1.29worker.worker1.type=ajp13worker.worker1.socket_keepalive=trueworker.jvm1.port=8009worker.jvm1.host=10.11.1.2worker.jvm1.type=ajp13worker.jvm1.socket_keepalive=true
2.配置httpd.conf:
在LoadModule配置部分加入一下内容:
LoadModule jk_module modules/mod_jk.so# Where to find workers.propertiesJkWorkersFile /usr/local/apache2.0.54/conf/workers.properties# Where to put jk logsJkLogFile
/usr/local/apache2.0.54/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 format JkRequestLogFormat "%w %V %T"
在VirtualHost配置如下内容:
NameVirtualHost *:80<VirtualHost 10.194.0.131:80>
ServerAdmin webmasterdemo
ServerName 10.11.1.29
DirectoryIndex index.jsp index.html
<Location "/">
</Location>
JkMount /* worker1</VirtualHost><VirtualHost 10.194.0.132:80>
ServerAdmin webmasterprint
ServerName 10.11.1.2
<Location "/">
</Location>
JkMount /* jvm1</VirtualHost>
三、配置tomcat:
1.修改10.11.1.29的server.xml文件:
找到<Engine>…</Engine>增加jvmRoute属性:
<Engine jvmRoute="worker1" className="org.apache.catalina.core.StandardEngine" backgroundProcessorDelay="10" baseDir="E:\Tomcat 5.0" debug="0" defaultHost="localhost" domain="Catalina" name="Catalina">…</Engine>
2.修改10.11.1.2的server.xml文件:
找到<Engine>…</Engine>增加jvmRoute属性:
<Engine jvmRoute="jvm1" className="org.apache.catalina.core.StandardEngine" backgroundProcessorDelay="10" baseDir="E:\Tomcat 5.0" debug="0" defaultHost="localhost" domain="Catalina" name="Catalina">…</Engine>
四、扩展功能:
可以配置多个tomcat作为相同web application的多个server,并使用apache的负载均衡特性,已做到相同web application的多个server之间的负载均衡,提高web访问效率。本文中例子并没有实现此特性。大家自己按着文档试试吧。
Apache与Tomcat整合问题的新方法
80酷酷网 80kuku.com