登录  /  注册
从apache负载均衡到nginx负载均衡 nginx 配置 rewrite nginx apache 比
php中文网
发布: 2016-07-29 08:52:34
原创
989人浏览过

第一次直接这样搞负载均衡,项目从apache变成nginx(其各自的优缺点自行百度)

服务器:A【代理】,B【tomcat1】,C【tomcat2】

一、剔除apache负载均衡模式
1、找到apache的安装文件,进入bin目录,停止httpd服务(./httpd -k stop)

2、修改tomcat下server.xml文件

apache nginx 比较,nginx,apache,apache nginx 共存,nginx apache,apache nginx tomcat,nginx 配置,rewrite,nginx apache 比

修改为

apache nginx 比较,nginx,apache,apache nginx 共存,nginx apache,apache nginx tomcat,nginx 配置,rewrite,nginx apache 比

二、安装nginx

略......自行百度

三、配置nginx负载均衡
1、找到nginx下的nginx.conf文件,修改

apache nginx 比较,nginx,apache,apache nginx 共存,nginx apache,apache nginx tomcat,nginx 配置,rewrite,nginx apache 比

完了,启动两台tomcat,启动nginx

出现502 ,定位原因,查找nginx的error.log文件(默认路径在/var/log/nginx/error.log)

发现权限问题

apache nginx 比较,nginx,apache,apache nginx 共存,nginx apache,apache nginx tomcat,nginx 配置,rewrite,nginx apache 比

百度后,初步定位在nginx.conf的配置文件里面

apache nginx 比较,nginx,apache,apache nginx 共存,nginx apache,apache nginx tomcat,nginx 配置,rewrite,nginx apache 比

这里出现的nginx,可能是这个用户的权限不足,改为root(不一定改成root,要改为有权限的用户)

发现还是出现502,可能还是没有找到具体原因,发现这样一篇文章:

apache nginx 比较,nginx,apache,apache nginx 共存,nginx apache,apache nginx tomcat,nginx 配置,rewrite,nginx apache 比

第一种方案:

apache nginx 比较,nginx,apache,apache nginx 共存,nginx apache,apache nginx tomcat,nginx 配置,rewrite,nginx apache 比

由于要重启,因为我是在测试环境里面玩的,没有重启,索性直接进行第二种方案

setsebool -P httpd_can_network_connect 1


接着访问代理服务器的地址,发现成功了,到此为止,nginx的负载均衡搭建完毕

PS:出现问题不要只看表面,刚开始一直在网上找nginx 502错误的原因,网上一大推没有用的东西,还是需要多看看日志,才能确定出问题出现在哪里

个人愚见,大神勿喷。。。。。

以上就介绍了从apache负载均衡到nginx负载均衡,包括了Apache,nginx方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 技术文章
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2023 //m.sbmmt.com/ All Rights Reserved | 苏州跃动光标网络科技有限公司 | 苏ICP备2020058653号-1

 | 本站CDN由 数掘科技 提供

登录PHP中文网,和优秀的人一起学习!
全站2000+教程免费学