잡담 배치

2831 단어
Flask + Gunicon + Nginx 배치
nginx 위치 vim / etc / nginx / nginx. conf / usr / local / openresty / nginx / sbin / nginx
vim i 삽입 esc: w 저장: q 종료
supervisor 명령 supervisorctl 서비스 감독자 재 시작
python 2 python 3 전환
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150

그리고 입력:
sudo update-alternatives --config python

nginx - s reload 포트 점용 보기
lsof -i:80

로 컬 덮어 쓰기 강제
git fetch --all  
git reset --hard origin/master 
git pull
#!/usr/bin/env python3
import sys
#            

from os.path import abspath
from os.path import dirname

sys.path.insert(0, abspath(dirname(__file__)))




#    app.py
import app

#         application    
# gunicorn       
#           Flask   
#        (  )
application = app


# -*- coding: utf-8 -*-
import os

from manage import app
import datetime

# Create an application instance that web servers can use. We store it as
# "application" (the wsgi default) and also the much shorter and convenient
# "app".
application = app

@app.context_processor
def template_extras():
    """
            ,                
    :return:
    """
    return {'enumerate': enumerate, 'len': len, 'datetime': datetime}

#          apache gunicorn nginx      
"""
➜  ~ cat /etc/supervisor/conf.d/python101.conf

[program:test]
command=/usr/local/bin/gunicorn wsgi --bind 0.0.0.0:80 --pid /tmp/todo.pid
directory=/root/tmp/test
autostart=true
"""/usr/local/bin/gunicorn -w 4 -b 127.0.0.1:81 manage:app
from manage import db
db.create_all()
python manage.py db

./venv/bin/gunicorn -w 4 -b 127.0.0.1:8080 manager:app



gunicorn --worker=3 manage:manager -b 0.0.0.0:8000

gunicorn -b 127.0.0.1:8000 -k gevent -w 1 manager.wsgi

gunicorn wsgi --bind 0.0.0.0:8000
gunicorn -b 127.0.0.1:8000 -k gevent -w 1 wsgi

[program:python101]
command=/usr/local/bin/gunicorn wsgi --bind 0.0.0.0:8000
directory=/var/www/python101
autostart=true
nano /etc/supervisor/conf.d/python101.conf

vim /etc/supervisor/conf.d/bbs.conf
vim /etc/supervisor/conf.d/python101.conf


[program:python101] command=/usr/local/bin/gunicorn wsgi --bind 0.0.0.0:8000 --pid /tmp/python101.pid directory=/root/var/www/python101 autostart=true autorestart=true


supervisorctl
service supervisor restart 

 cat /etc/nginx/sites-enabled/chat
 vim /etc/nginx/sites-enabled/python101
 rm /etc/nginx/sites-enabled/python101

 service nginx restart

 cat /etc/nginx/sites-enabled/python101
 cat /etc/nginx/nginx.conf
 vim /etc/nginx/sites-enabled/chat
 vim /etc/supervisor/conf.d/python101.conf

좋은 웹페이지 즐겨찾기