• 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访问 

  • 相关阅读:
    Linux下安装配置SVN服务器,windows访问
    Zookeeper集群版搭建
    Zookeeper单机版启动
    Nginx-Session缓存一致性-memcached
    Nginx-配置多台Tomcat-反向代理
    Linux-tomcat-安装启动
    Linux-JDK-环境搭建安装
    Nginx-安装-运行访问页面
    Linux-虚拟机-克隆-学习
    解决CocosCreator 在微信小游戏中使用Socket.io 报错的问题
  • 原文地址:https://www.cnblogs.com/ExMan/p/10775426.html
Copyright © 2020-2023  润新知