1.安装Apache 2.2.x
安装过程略
httpd -version
Server version: Apache/2.2.3
Server built: Jul 15 2009 09:02:25
2.下载mod_jk For Apache 2.2.x
下载mod_jk,
http://tomcat.apache.org/connectors-doc/,注意版本号是否和Apache匹配,同时也要注意32位和64位的版本。
3.mod_jk的属性配置,workers.properties
cat /etc/httpd/conf/workers.properties
#
worker.list=LoadBalancer,jkstatus
worker.jkstatus.type=status
# Now we define the load-balancing behaviour
worker.LoadBalancer.type=lb
#定义负载均衡节点
worker.LoadBalancer.balance_workers=node1,node2
#设置是否开启粘性会话共享,还需要设置JBOSS的UseJK和jvmRoute属性
worker.LoadBalancer.sticky_session=true
worker.LoadBalancer.method=R
worker.LoadBalancer.retries=2
#JBOSS的AJP端口
worker.node1.port=2081
worker.node1.host=localhost
worker.node1.type=ajp13
worker.node1.fail_on_status=500
worker.node1.cachesize=100
worker.node1.connection_pool_size=50
worker.node1.connection_pool_minsize=25
worker.node1.connection_pool_timeout=600
#JBOSS的AJP端口
worker.node2.port=2082
worker.node2.host=localhost
worker.node2.type=ajp13
worker.node2.fail_on_status=500
worker.node2.cachesize=100
worker.node2.connection_pool_size=50
worker.node2.connection_pool_minsize=25
worker.node2.connection_pool_timeout=600
4.mod_jk的转发配置,uriworkermap.properties
cat /etc/httpd/conf/uriworkermap.properties
/*=LoadBalancer
/=LoadBalancer
#
# Mount jkstatus to /jkmanager
# For production servers you will need to
# secure the access to the /jkmanager url
#
/jkmanager=jkstatus
5.添加mod_jk配置文件
cat /etc/httpd/conf/mod_jk.conf
# Load mod_jk module. Specify the filename
# of the mod_jk lib you’ve downloaded and
# installed in the previous section
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile conf/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel error
# Select the log format
JkLogStampFormat "[%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"
6.配置mod_jk
- 复制mod_jk.conf到Apache的安装目录下的conf目录,如:/etc/httpd/conf/
- 复制workers.properties到Apache的安装目录下的conf目录,如:/etc/httpd/conf/
- 复制uriworkermap.properties到Apache的安装目录下的conf目录,如:/etc/httpd/conf/
- 修改httpd.conf,找到Include的地方在前面添加:Include conf/mod_jk.conf
Include conf/mod_jk.conf
Include conf.d/*.conf
7.配置mod_jk