首页 > 服务器    日期:2018-10-02 / 来自互联网 / 浏览

1.测试环境

linode家Centos6.8 64bit镜像

2.安装步骤

1.安装uwsgi容器

https://uwsgi-docs.readthedocs.io/en/latest/

2.安装c环境

yum -y install gcc gcc-c++

3.安装setuptools

wget https://bootstrap.pypa.io/ez_setup.py

sudo python ez_setup.py
4.安装pip

wget https://bootstrap.pypa.io/get-pip.py

sudo python get-pip.py

5.安装python-devel

sudo yum install python-devel

6.安装uwsgi

pip install uwsgi

3.简单helloworld的部署

1.安装flask

pip install flask

2.helloword 程序

from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
    return 'Hello World!'
if __name__ == '__main__':
    app.run(host='0.0.0.0')

3.安装nginx

cd /etc/yum.repos.d/
vi nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1
yum install nginx -y

4.修改nginx配置信息

location / { try_files $uri @yourapplication; }
location @yourapplication {
    include uwsgi_params;
    uwsgi_pass unix:/tmp/uwsgi.sock;
}

5.启动

注意 uwsgi和nginx的权限必须统一

假设网站入口文件为app.py

则先启动uwsgi

uwsgi -s /tmp/uwsgi.sock -w app:app --chmod-sock=777

再启动nginx

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章