日期:2014-05-16  浏览次数:20737 次

负载均衡apache在linux系统安装部署

?

?

下载安装包:httpd-2.4.1.tar.bz2和httpd-2.4.1-deps.tar.bz2,拷贝到/usr/local/src目录下

进行解压文件

?

1. #bunzip2 httpd-2.2.11.tar.bz2 //对软件包解压缩

2. //当前目录下多了一个tar文件 ,(httpd-2.2.11.tar.bz2会自动删除,生成httpd-2.2.11.tar)
3. 解压httpd-2.2.11.tar
#tar xvf httpd-2.2.11.tar

运行源代码目录下的configure命

?

解压缩后,进入源码的目录httpd-2.2.11,并使用配置脚本进行环境的设置。相应的命令为:
#./configure

?

安装依赖包

# 编译和安装 apr

进入apr目录(usr/local/src/httpd-2.4.1/ srclib)

./configure --prefix=/usr/local/apr

Make

Make install

# 编译和安装 apr-util

进入apr-util目录(usr/local/src/httpd-2.4.1/ srclib)

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

Make

Make install

?

安装 apache

进入apache2目录(usr/local)

./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-cgi --enable-rewrite --enable-deflate --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-mpm=worker

Make

Make install

?

集群部署:在apache/conf/中打开httpd.conf,在后面添加:

ProxyPas/ balancer://tomcatcluster/ lbmethod=byrequests stickysession=JSESSIONID nofailover=Off timeout=5 maxattempts=3

ProxyPassReverse / balancer://tomcatcluster/

<Proxy balancer://tomcatcluster>

BalancerMember ajp://localhost:8109 route=tomcat1

BalancerMember ajp://localhost:8209 route=tomcat2

</Proxy>

?