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_jk LoadModule jk_module modules/mod_jk.so JkWorkersFile conf/workers.properties JkLogFile logs/mod_jk.log JkLogLevel debug JkMount /* myCluster
3.创建workers.properties
[root@centos2 conf]# vi workers.properties
worker.list=myCluster worker.TomcatA.port=8009 worker.TomcatA.host=192.168.146.128 worker.TomcatA.type=ajp13 worker.TomcatA.lbfactor=1 worker.TomcatB.port=8009 worker.TomcatB.host=192.168.146.130 worker.TomcatB.type=ajp13 worker.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.so LoadModule proxy_connect_module modules/mod_proxy_connect.so LoadModule proxy_ftp_module modules/mod_proxy_ftp.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so LoadModule proxy_scgi_module modules/mod_proxy_scgi.so LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so LoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule proxy_express_module modules/mod_proxy_express.so LoadModule slotmem_shm_module modules/mod_slotmem_shm.so LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
将mod_jk.conf配置加载到系统中:
Include conf/httpd-jk.conf
5.启动apache
[root@centos2 bin]# ./apachectl start
6.测试
http://192.168.146.130/dudada
页面显示正常表示配置成功了!