zoukankan      html  css  js  c++  java
  • flask,gunicorn,supervisor,nginx配置服务器接口

    1,申请阿里云主机

    2,apt-get update

    3,apt-get install pip

    4,pip install virtualenv

    5,virtualenv venv

    6,source venv/bin/activate

    7,pip install flask

    8,vim myapp.py

    from flask import Flask

    app = Flask(__name__)

    @app.route('/')

    def index():

        return 'hello world !'

    if __name__ == '__main__':

        app.debug =True

        app.run()

    9,apt-get install nginx

    查询nginx错误:nginx -t -c /etc/nginx/nginx.conf

    10,修改nginx配置

    vim /etc/nginx/sites-available/default

    vim /etc/nginx/sites-enabled/default

    server {

        listen 80;

        server_name xxxxxxxx;

        client_max_body_size 10M;

        location / {

            proxy_pass http://0.0.0.0:8000;

            proxy_redirect off;

            proxy_set_header Host $host;

            proxy_set_header X-Real-IP $remote_addr;

            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }

    }

    service nginx start

    service nginx restart

    11,安装supervisor

    pip install supervisor

    12,配置supervisor

    echo_supervisord_conf > supervisor.conf

    [program:myapp]

    command=/root/venv/bin/gunicorn -w 4 -b 0.0.0.0:8000 myapp:app

    directory=/root

    startsecs=0

    stopwaitsecs=0

    autostart=true

    autorestart=true

    stdout_logfile=/root/log/gunicorn.log

    stderr_logfile=/root/log/gunicorn.err

    13,启动supervisor

    supervisord -c supervisor.conf

    supervisorctl -c supervisor.conf start all

    14,配置阿里云网络安全

    15,使用阿里云服务器公网ip访问 

  • 相关阅读:
    git更新或者还原本地代码
    log4net配置文件
    用ASP.NET MVC仿站糗事百科
    为表创建索引
    VisualStudio2008+水晶报表的使用
    C#中的位的或运算的理解
    char.IsLetter的使用
    C# 邮箱的使用
    NPOI DataTable导出excel
    NPOI DataSet导出excel
  • 原文地址:https://www.cnblogs.com/ExMan/p/10775426.html
Copyright © 2011-2022 走看看