1.首先查看Linux 系统信息
版本:cat /etc/*release
系统信息:lsb_release -a
查看位数:getconf LONG_BIT
我的是centos6.6 64位
源码安装前必备软件 apr,apr-util,pcre 查看命令
yum list installed | grep -E "pcre|apr"
apr.x86_64 1.3.9-5.el6_2 @base
apr-util.x86_64 1.3.9-3.el6_0.1 @base
apr-util-ldap.x86_64 1.3.9-3.el6_0.1 @base
pcre.x86_64 7.8-6.el6 @anaconda-CentOS-201410241409.x86_64/6.6
没有结果
安装apr ,apr-util,
wget http:
//apache.fayea.com/apache-mirror//apr/apr-1.5.0.tar.gz
wget http:
//apache.fayea.com/apache-mirror//apr/apr-util-1.5.3.tar.gz
wget http://sourceforge.net/projects/pcre/files/pcre/Download pcre2-10.20.zip (2.0 MB)(http://pcre.org/)
2.解压完后编译安装命令:
./configure --prefix=/usr/local/apr (注意:configure安装的文件夹目录可以自己定义 /usr/local/apr )
make
make install
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with- pcre=/usr/local/pcre --enable-module=shared
make
make install
安装jk 下载源码参照上述步骤编译安装 wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz
3.Apache + tomcat +jk 负载均衡配置
3.1)APR(Apache portable Run-time libraries) Apache 可移植 运行库,跨越操作系统提空底层支持接口库
进入conf目录 vim httpd.conf
ServerRoot "/usr/local/apache" #Apache 安装路径
Listen 80 #服务器监听端口
LoadModule jk_module modules/mod_jk.so#加载模块
3.2) 加上
JkWorkersFile conf/workers.properties#负载方式配置
JkMountFile conf/uriworkermap.properties#请求url的处理
JkLogFile logs/mod_jk.log#jk日志文件
JkLogLevel warn#日志输出级别
vim workers.properties
# list the workers by name
worker.list=DLOG4J, status
# localhost server 1
# ------------------------
worker.s1.port=8109#tomcat ajp 通信端口
worker.s1.host=localhost#服务器1{ip地址}
worker.s1.type=ajp13
# localhost server 2
# ------------------------
worker.s2.port=8209 #tomcat ajp 通信端口
worker.s2.host=localhost#服务器2
worker.s2.type=ajp13
worker.s2.stopped=1
worker.DLOG4J.type=lb
worker.retries=3
worker.DLOG4J.balanced_workers=s1, s2
worker.DLOG4J.sticky_session=1
worker.status.type=status
vim uriworkermap.properties
/*=DLOG4J
/jkstatus=status
!/*.gif=DLOG4J
!/*.jpg=DLOG4J
!/*.png=DLOG4J
!/*.css=DLOG4J
!/*.js=DLOG4J
!/*.htm=DLOG4J
!/*.html=DLOG4J
以上配置完毕