标签:process bash source ret img wsgi pass vhost amp
环境:
1.centos7
2.python2
3.flask1.1.2
4.nginx
1.安装python虚拟环境
pip install virtualenv
2.创建虚拟环境
mkdir flask_project cd flask_project virtualenv venv
3.在虚拟环境里安装flask
source source venv/bin/activate pip install flask
4.创建flask项目
vim myapp.py
from flask import Flask app = Flask(__name__) @app.route(‘/‘) def index(): return "I am a flask example!"
5.安装nginx
yum install nginx -y
6.全局安装或者虚拟环境uwsgi
pip install uwsgi
7.编写uwsgi文件
[uwsgi] #socket = 127.0.0.1:3031 socket = /run/mysite.sock chdir = /opt/flask_project wsgi-file = myapp.py callable = app #http = 127.0.0.1:9191 virtualenv = /opt/flask_project/venv daemonize = /var/log/uwsgi.log processes = 4 uid = root gid = root
8.编写并导入nginx配置文件
vim /etc/nginx/vhost/flask.conf
server { listen 8000 default_server; listen [::]:8000 default_server; server_name localhostA; include /etc/nginx/default.d/*.conf; index index.html index.htm; location / { include uwsgi_params; uwsgi_pass unix:///run/mysite.sock; } }
在/etc/nginx/nginx.conf里添加以下内容
include /etc/nginx/vhost/*.conf;
9.启动uwsgi和重启nginx
10.项目详情:
include /etc/nginx/vhost/*.conf;
centos+python2+flask+nginx+uwsgi环境搭建
标签:process bash source ret img wsgi pass vhost amp
原文地址:https://www.cnblogs.com/navysummer/p/12874814.html