1.安装mod_jk
[root@centos2 software]# wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz
[root@centos2 software]# tar xzvf tomcat-connectors-1.2.40-src.tar.gz
[root@centos2 software]# cd tomcat-connectors-1.2.40-src
[root@centos2 tomcat-connectors-1.2.40-src]# cd native/
[root@centos2 native]# ./configure --with-apxs=/usr/local/apache2/bin/apxs
[root@centos2 native]# make
[root@centos2 native]# cd apache-2.0/
[root@centos2 apache-2.0]# ls
bldjk54.qclsrc config.m4 Makefile.apxs Makefile.in mod_jk.a mod_jk.dsp mod_jk.lo mod_jk.so
bldjk.qclsrc Makefile Makefile.apxs.in Makefile.vc mod_jk.c mod_jk.la mod_jk.o NWGNUmakefile
[root@centos1 apache-2.0]# cp mod_jk.so /usr/local/apache2/modules/
2.创建httpd-jk.conf
[root@centos2 conf]# vi httpd-jk.conf
# Load the mod_jkLoadModule jk_module modules/mod_jk.soJkWorkersFile conf/workers.properties JkLogFile logs/mod_jk.logJkLogLevel debugJkMount /* myCluster
3.创建workers.properties
[root@centos2 conf]# vi workers.properties
worker.list=myCluster worker.TomcatA.port=8009worker.TomcatA.host=192.168.146.128worker.TomcatA.type=ajp13worker.TomcatA.lbfactor=1 worker.TomcatB.port=8009worker.TomcatB.host=192.168.146.130worker.TomcatB.type=ajp13worker.TomcatB.lbfactor=1 worker.myCluster.type=lb worker.myCluster.balance_workers=TomcatA,TomcatB worker.myCluster.sticky_session = 0
4.配置httpd.conf
[root@centos2 conf]# vi httpd.conf
将以下module注释去掉:
LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_connect_module modules/mod_proxy_connect.soLoadModule proxy_ftp_module modules/mod_proxy_ftp.soLoadModule proxy_http_module modules/mod_proxy_http.soLoadModule proxy_fcgi_module modules/mod_proxy_fcgi.soLoadModule proxy_scgi_module modules/mod_proxy_scgi.soLoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.soLoadModule proxy_ajp_module modules/mod_proxy_ajp.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.soLoadModule proxy_express_module modules/mod_proxy_express.soLoadModule slotmem_shm_module modules/mod_slotmem_shm.soLoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.soLoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.soLoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.soLoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
将mod_jk.conf配置加载到系统中:
Include conf/httpd-jk.conf
5.启动apache
[root@centos2 bin]# ./apachectl start
6.测试
页面显示正常表示配置成功了!