Tomcat一步步实现反向代理、负载均衡、内存复制---mod_jk连接器
五.apache做前端代理,基于mod_jk模块与Tomcat连接
5.1 编译安装mod_jk模块,下载地址:http://mirrors.tuna.tsinghua.edu.cn/apache//tomcat/tomcat-connectors/jk/
tar xvf tomcat-connectors-1.2.37-src.tar.gz
cd tomcat-connectors-1.2.37-src
cd native/
./configure --with-apxs=/usr/local/apache/bin/apxs
make && make install
5.2 apache要使用mod_jk连接器,需要在启动时加载此连接器模块。为了便于管理与mod_jk模块相关的配置,这里使用一个专门的配置文件/etc/httpd/extra/httpd-jk.conf来保存相关指令及其设置。其内容如下:
vi /etc/httpd/extra/httpd-jk.conf
# Load the mod_jk
LoadModule jk_module modules/mod_jk.so
JkWorkersFile /etc/httpd/extra/workers.properties
JkLogFile logs/mod_jk.log
#JkLogLevel debug
JkMount /* linuxidc
JkMount /status/ status
5.3 建立mod_jk需要的配置文件
vi /etc/httpd/extra/workers.properties
worker.list=linuxidc,status
worker.linuxidc.port=8009
worker.linuxidc.host=172.16.1.22
worker.linuxidc.type=ajp13
worker.linuxidc.lbfactor=1
worker.status.type = status
5.4 在/etc/httpd/httpd.conf中把/etc/httpd/extra/httpd-jk.conf 包含进来,并注释掉虚拟主机,与其中的代理会冲突的哦
vi /etc/httpd/httpd.conf
#Include /etc/httpd/extra/httpd-vhosts.conf
Include /etc/httpd/extra/httpd-jk.conf
##重启httpd
service httpd restart
5.5 访问http://jsprun.linuxidc.com/测试,能否能看到jsprun