标签:rom listen 解压 inf ror events lazy open nbsp
1.下载地址 https://nginx.org/download/ 解压
2. 配置
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx
make make install
3.基本命令
./nginx 开启
./nginx -s stop 停止
./nginx -s quit
./nginx -s reload
4.配置conf 负载均衡demo
(1).随便写两个服务
a服务
# -*- coding: UTF-8 -*-
from flask import Flask, jsonify
from flask import request
app = Flask(__name__)
@app.route(‘/‘)
def hello_world():
return ‘GO!‘
if __name__ == ‘__main__‘:
app.run(host="0.0.0.0", port=5001, debug=False)
b服务
# -*- coding: UTF-8 -*-
from flask import Flask, jsonify
from flask import request
app = Flask(__name__)
@app.route(‘/‘)
def hello_world():
return ‘GO! XN‘
if __name__ == ‘__main__‘:
app.run(host="0.0.0.0", port=5000, debug=False)
(2)配置nginx 文件
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream group1{
server 192.168.203.137:5000 weight=5;
server 192.168.203.137:5001 weight=1;
}
server {
listen 80;
server_name localhost;
location /{
proxy_pass http://group1/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
(3)测试 http://ip/
访问6次 五次b服务 一次a服务
标签:rom listen 解压 inf ror events lazy open nbsp
原文地址:https://www.cnblogs.com/xiennnnn/p/13072316.html