JBoss EAP 6与Apache通信的mod_jk配置

阅读更多

安装Apache

    以下是httpd 2.2的安装步骤(如使用httpd 2.4,请参考Linux下安装Apache HTTP Server 2.4):

1. 安装

    下载解压后进入httpd的根目录,依次执行如下命令:

     # ./configure --prefix=PREFIX --enable-so --enable-mods-shared=most --enable-ssl
     # make
     # make install

安装完毕后可执行以下命令启动apache:
     $ PREFIX/bin/apachectl start

注意:PREFIX要替换为Apache的安装目录,如/usr/local/apache2.2

 2. 配置为service

     将apachectl拷贝到init.d

     # cp apachectl /etc/init.d/httpd

     # chkconfig --add httpd
     # chkconfig httpd on

     # service httpd start

 

安装mod_jk

    下载mod_jk, 解压后进入native目录,执行如下命令:

    ./configure --with-apxs=/usr/local/apache2.2/bin/apxs
     make

    编译成功后,进入native/apache-2.0目录,将mod_jk.so拷贝到Apache的modules目录下。

 

配置mod_jk

    在Apache的conf目录中创建三个文件:mod-jk.conf、workers.properties、uriworkermap.properties,内容如下:

mod-jk.conf

# Load mod_jk module
# Update this path to match your modules location
LoadModule jk_module modules/mod_jk.so
 
# Declare the module for
#AddModule mod_jk.c
 
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile conf/workers.properties
 
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile logs/mod_jk.log
 
# Set the jk log level [debug/error/info]
JkLogLevel info
 
# 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"
 
# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile logs/jk.shm
 
# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
JkMountFile conf/uriworkermap.properties

# Add jkstatus for managing runtime data

    JkMount status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1

 

workers.properties

# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status

# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.reference=worker.template
worker.node1.host=192.168.50.1
worker.node1.port=8009
worker.node1.lbfactor=1

 

# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.reference=worker.template
worker.node2.host=192.168.50.2
worker.node2.port=8009
worker.node2.lbfactor=2

worker.template.type=ajp13
worker.template.socket_connect_timeout=5000
worker.template.socket_keepalive=true
worker.template.connection_pool_minsize=0
worker.template.connection_pool_timeout=600
worker.template.ping_mode=A
 
# Load-balancing behaviour 
worker.loadbalancer.type=lb 
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=true

# Status worker for managing load balancer
worker.status.type=status

 

uriworkermap.properties

/signac-web|/*=loadbalancer

#
# Mount jkstatus to /jkmanager
# For production servers you will need to
# secure the access to the /jkmanager url
#
/jkstatus=status

    最后在httpd.conf文件中添加:

    Include conf/mod-jk.conf

 

配置EAP

     mod_jk使用AJP协议进行通讯,需在web subsystem中配置 ajp connector;

     另外需配置jvmRoute,如未配置sticky_session是不起作用的。在EAP6中需添加属性instance-id="node1"(名称要与workers.properties中一致),如下:

     
           
           
            ....
       

     绑定ajp端口

     
        ...
       

       

        ....

      

 

测试

测试页面:

      jkstatus: http://127.0.0.1/jkstatus

      signac-web: http://127.0.0.1/signac-web

 

附录

1. 如使用YUM安装apache,需执行

yum install httpd

yum install httpd-devel

httpd-devel中包含apxs。

2. 安装apache, 执行./configure命令时,输出:

checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

原因是没有安装zlib包。centos下可执行yum install zlib-devel, ubuntu下可执行apt-get install zlib1g-dev来安装。

3. 启用ssl

yum install mod_ssl openssl

4. 升级openssl时注意使用--shared,否则可能会提示版本冲突

./config --prefix=/usr --shared

你可能感兴趣的:(EAP,6,Apache,mod_jk,sticky,session)