centos7安装apache做负载均衡

时间:2015-01-31 00:16来源:转载 作者:转载 举报 点击:

一、安装apache .

       yum -y  install httpd

 

     安装在了 /etc/httpd目录下

二、安装 mod_jk

      去http://tomcat.apache.org/connectors-doc/或者http://tomcat.apache.org/页面最下面下载

Tomcat Connectors 1.2.40 Released

三、解压编译安装tomcat-connectors-1.2.40-src.tar

 如果没有 /usr/bin/apxs 则安装apxs
 
 yum -y install apr-util-devel
 yum -y install httpd-devel
 tar -zxvf tomcat-connectors-1.2.40-src.tar
 cd tomcat-connectors-1.2.40-src/native
 ./configure  --with-apxs=/usr/bin/apxs
 make && make install

四、拷贝tomcat-connectors-1.2.40-src/native/apache-2.0/mod_jk.so到 /etc/httpd/modules/目录下

 

       cp tomcat-connectors-1.2.40-src/native/apache-2.0/mod_jk.so  /etc/httpd/modules

 

五、配置

    vi /etc/httpd/conf/httpd.conf
   添加

Include /etc/httpd/conf/mod_jk.conf

六、

/etc/httpd/conf/

下建立

mod_jk.conf

文件。配置内容

 

LoadModule jk_module /etc/httpd/modules/mod_jk.so
JkWorkersFile /etc/httpd/conf/workers.properties
JkMountFile /etc/httpd/conf/uriworkermap.properties
JkLogFile /etc/httpd/logs/mod_jk.log
JkLogLevel warn
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
#JkMount /*.* controller

七、在
/etc/httpd/conf/
下建立配置workers.properties文件
worker.list=controller,status

worker.tomcat129.port=8009
worker.tomcat129.host=192.168.152.129
worker.tomcat129.type=ajp13
worker.tomcat129.lbfactor=1

worker.tomcat130.port=8009
worker.tomcat130.host=192.168.152.130
worker.tomcat130.type=ajp13
worker.tomcat130.lbfactor=1

worker.controller.type=lb
worker.controller.balance_workers=tomcat129,tomcat130
worker.controller.sticky_session=0

worker.status.type=status

八、在
/etc/httpd/conf/
下建立配置uriworkermap.properties文件

/*=controller
#/jkstatus=status
#!/*.gif=controller
#!/*.jpg=controller
#!/*.png=controller
#!/*.css=controller
#!/*.js=controller
#!/*.htm=controller
#!/*.html=controller


负载均衡配置好了 

启动如果报错 

修改httpd.conf文件 找到ServerName添加
#ServerName www.example.com:80

ServerName localhost:80

剩下session复制了
------分隔线----------------------------
发表评论
为了和诣的生活,我关闭了评论页面,请大家到QQ群里交流吧:348944156,也欢迎关注本站微信公众号:centoscn