centos7安装apache做负载均衡

分类:CentOS运维 阅读:3503 次

一、安装apache .

yum-y installhttpd

安装在了 /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-yinstallapr-util-devel yum-yinstallhttpd-devel

 tar-zxvftomcat-connectors-1.2.40-src.tar cdtomcat-connectors-1.2.40-src/native ./configure--with-apxs=/usr/bin/apxs make&&makeinstall

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

cptomcat-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

文件。配置内容

 LoadModulejk_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 JkLogLevelwarn 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添加 #ServerNamewww.example.com:80 ServerNamelocalhost:80 剩下session复制了