=============================================
个人操作记录:
config:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
upstream myServer{
server 192.168.2.131:80 weight=9; #这里是你自己要做负载均衡的服务器地址1
server 192.168.2.162:8080 weight=1; #这里是要参与负载均衡的地址2
}
server {
listen 8080;
server_name localhost;
location / {
proxy_pass http://myServer;
}
}
sendfile on;
keepalive_timeout 65;
}
./nginx -s stop
./nginx -c /usr/local/bin/nginx-1.7.9/conf/nginx.conf
./nginx -s reload
=============================================
请看原文 地址:https://www.cnblogs.com/xxx91hx/p/4245901.html
[root@localhost src]# wget http://nginx.org/download/nginx-1.7.9.tar.gz
[root@localhost src]# tar zxvf nginx-1.7.9.tar.gz
[root@localhost nginx-1.7.9]# yum -y install gcc-c++
[root@localhost nginx-1.7.9]# yum -y install pcre-devel
[root@localhost nginx-1.7.9]# yum -y install zlib-devel
[root@localhost nginx-1.7.9]# ./configure --prefix=/usr/etc/ngin
[root@localhost nginx-1.7.9]# make
[root@localhost nginx-1.7.9]# make install
启动nginx
[root@localhost nginx-1.7.9]# cd /usr/etc
[root@localhost etc]# ls
ngin
[root@localhost etc]# cd ngin
[root@localhost ngin]# ls
conf html logs sbin
[root@localhost ngin]# cd sbin
[root@localhost sbin]# ls
nginx
[root@localhost sbin]# ./nginx
查看是否启动
[root@localhost sbin]# ps -ef|grep nginx
重启
[root@localhost sbin]# ./nginx -s reload
暂停
[root@localhost sbin]# ./nginx -s stop
访问 http://192.168.1.103/