1、查看是否有mod_proxy_http.so、mod_proxy_balancer.so、mod_proxy.so三个模块
# ll /usr/local/apache2/modules
2、加载模块
# cd /usr/local/src/httpd-2.2.23/modules/proxy/
# /usr/local/apache2/bin/apxs -c -i mod_proxy.c proxy_util.c
# /usr/local/apache2/bin/apxs -c -i mod_proxy_balancer.c
# /usr/local/apache2/bin/apxs -c -i mod_proxy_http.c
3、修改http.conf配置文件
# vim /usr/local/apache2/conf/httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyRequests Off
<Proxy balancer://clusterphpinfo>
BalancerMember http://10.0.2.203:80 loadfactor=1
BalancerMember http://10.0.2.204:80 loadfactor=1
</Proxy>
ProxyPass / balancer://clusterphpinfo
4、重启httpd服务
# service httpd restart
5、通过apache将后端服务器做出主从,只需要在从服务器后面添加status=+H
# vim /usr/local/apache2/conf/httpd.conf
BalancerMember http://10.0.2.204:80 loadfactor=1 status=+H
本文出自 “kimileonis” 博客,请务必保留此出处http://kimileonis.blog.51cto.com/5531747/1551621
原文地址:http://kimileonis.blog.51cto.com/5531747/1551621