Apache2.4 + Tomcat6集群配置笔记

一、安装Apache

1、修改httpd.conf中的路径c:/Apache24为Apache安装包的路径,如:D:/httpd-2.4.12/Apache24

2、进入Apache安装目录下的bin目录:

httpd.exe-kinstall

3、启动服务httpd.exe-w-n"Apache2.4"-kstart

(卸载服务scdeleteApache2.4)

二、配置Apache

1、打开conf/httpd.conf文件,加载以下模块

LoadModuleproxy_modulemodules/mod_proxy.so

LoadModuleproxy_ajp_modulemodules/mod_proxy_ajp.so

LoadModulerewrite_modulemodules/mod_rewrite.so

LoadModuleproxy_balancer_modulemodules/mod_proxy_balancer.so

LoadModuleproxy_connect_modulemodules/mod_proxy_connect.so

LoadModuleproxy_ftp_modulemodules/mod_proxy_ftp.so

LoadModuleproxy_http_modulemodules/mod_proxy_http.so

LoadModuleslotmem_shm_modulemodules/mod_slotmem_shm.so

LoadModulespeling_modulemodules/mod_speling.so

LoadModulessl_modulemodules/mod_ssl.so

LoadModulelbmethod_byrequests_modulemodules/mod_lbmethod_byrequests.so

2、去掉Includeconf/extra/httpd-vhosts.conf前面的注释符

3、在文件末尾添加反向代理

ProxyRequestsOff

<proxybalancer://cluster>

BalancerMemberajp://127.0.0.1:11007loadfactor=1route=tomcat1

BalancerMemberajp://127.0.0.1:11008loadfactor=1route=tomcat2

BalancerMemberajp://127.0.0.1:11009loadfactor=1route=tomcat3

</proxy>

4、打开conf/extra/httpd-vhosts.conf文件,配置虚拟站点

<VirtualHost*:80>

[email protected]

ServerNamelocalhost

ServerAliaslocalhost

ProxyPass/balancer://cluster/stickysession=jsessionidnofailover=On

ProxyPassReverse/balancer://cluster/

ErrorLog"logs/lbtest-error.log"

CustomLog"logs/lbtest-access.log"common

</VirtualHost>

三、配置tomcat

1、复制3个tomcat

2、修改tomcat2的server.xml

<Serverport="8005"shutdown="SHUTDOWN">把port改为8006

<ConnectorconnectionTimeout="20000"port="8080"protocol="HTTP/1.1"redirectPort="8443"/>把port改为8090

<Connectorport="11008"protocol="AJP/1.3"redirectPort="8443"/>把port改为11008

<EnginedefaultHost="localhost"name="Catalina">添加jvmRoute="tomcat2",在tomcat1中同样添加jvmRoute="tomcat1"

打开<Clusterclassname="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>注释

3、修改tomcat3的server.xml,同tomcat2,把port改为11009,添加jvmRoute="tomcat3",保证3个tomcat的端口都不相同,并且AJP的的端口和httpd.conf文件中配置的代理端口一致。

四、在项目中的web.xml文件的<web-app>节点下加入<distributable/>

相关推荐