首先安装apache依赖的apr和apr-util
1.下载(apr.apache.org/download.cgi)源文件, 如apr-1.5.1.tar.gz
2.解压 tar -xzvf apr-1.5.1.tar.gz
3.进入解压目录,依次执行
|
1
2
3
|
./configure
makemake?install
|
4.下载(apr.apache.org/download.cgi)源文件, 如apr-util-1.5.4.tar.gz
5.解压 tar -xzvf apr-util-1.5.4.tar.gz
6.进入解压目录,依次执行
|
1
2
3
|
./configure?--with-apr=/usr/local/apr
makemake?install
|
?
安装apache
1.下载(httpd.apache.org/download.cgi)源文件, 如httpd-2.4.10.tar.gz
2.解压 tar -xzvf httpd-2.4.10.tar.gz
?
3.进入解压目录,依次执行
|
1
2
3
4
|
./configure?--prefix=/usr/local/apache?--enable-so
makemake?install
bin/apachectl?-k?start?#启动apache,访问显示it works,表示安装ok
|
4.添加服务
|
1
2
3
4
|
cp?bin/apachectl?/etc/rc.d/init.d/apache
vim?/etc/rc.d/init.d/apache?#编辑此文件,添加一行:‘#chkconfig:?2345??85?15‘,可放到第二行(#/bin/sh下面)
chkconfig?--add?apache?#添加服务
service?apache?start?#启动服务
|
?
配置负载均衡和会话保持
1.修改apache_home/conf/httpd.conf,增加以下模块(取消注释,如有其他依赖, 则相应取消注释)
|
1
2
3
|
LoadModule?proxy_module?modules/mod_proxy.so
LoadModule?proxy_http_module?modules/mod_proxy_http.so
LoadModule?proxy_balancer_module?modules/mod_proxy_balancer.so
|
2修改apache_home/conf/httpd.conf,配置VirtualHost实现负载均衡和会话保持,增加下面节点
|
1
2
3
4
5
6
7
8
9
10
11
12
|
<VirtualHost?*>
????Header?add?Set-Cookie?"routeId=.%{BALANCER_WORKER_ROUTE}e;path=/"?env=BALANCER_ROUTE_CHANGED?<!--设置cookie用来实现会话保持-->
????ProxyRequests?Off
????ProxyPreserveHost?On
????????Order?Deny,Allow
????????Allow?from?all
????????BalancerMember?http://150.20.20.91:8001?route=server1
????????BalancerMember?http://150.20.20.92:8001?route=server2
????</Proxy>
</VirtualHost>
|
原文:http://kmvyo.iteye.com/blog/2157458