大佬教程收集整理的这篇文章主要介绍了centos6.7上使用nginx实现负载均衡!,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
实现环境:
vmware workstation 11
@H_301_6@centos6.7的系统下
Nginx服务器:192.168.239.136 防火墙关闭 setenforce 0
@H_301_6@apache服务器1:192.168.239.138 防火墙关闭 setenforce 0 @H_301_6@apache服务器2:192.168.239.139 防火墙关闭 setenforce 0@H_301_6@SecureCRT (ssh远程连接软件)
@H_301_6@@H_301_6@软件介绍:
@H_301_6@Nginx介绍@H_301_6@试验流程:
@H_301_6@一、软件安装@H_301_6@[root@localhost ~]# yum install -y Nginx
@H_301_6@注释:centos的官方的yum源里面不包含Nginx,所以我们想使用yum的话 就需要配置一下epel源@H_301_6@http://www.centoscn.com/CentOS/config/2014/0920/3793.html @H_301_6@
include /etc/Nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forWARDed_for"';
access_log /var/log/Nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#增加的
upstream web1 {
server 192.168.239.139:80 weight=1 max_fails=2 fail_timeout=30s;
server 192.168.239.138:80 weight=1 max_fails=2 fail_timeout=30s;
}
#增加的
server {
listen 80;
server_name localhost;
proxy_pass http://web1;
root html;
index index.html index.htm;
}
}
#gzip on;
# Load config files from the /etc/Nginx/conf.d directory
# The default server is in conf.d/default.conf
#include /etc/Nginx/conf.d/*.conf; #这里需要注释掉,不然起不到作用。
}
三、重启Nginx
[root@localhost ~]# /usr/sbin/Nginx -s reload
六、在我的物理机上测试!
在浏览器里输入Nginx的ip
刷新
谢谢大家
以上是大佬教程为你收集整理的centos6.7上使用nginx实现负载均衡!全部内容,希望文章能够帮你解决centos6.7上使用nginx实现负载均衡!所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。