码迷,mamicode.com
首页 > 其他好文 > 详细

django 1.9 wsgi + nginx

时间:2016-03-09 15:35:34      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

  • install django

pip install django

 

create django project

django-admin.py startproject mysite
cd mysite

 

install uwsgi (rhel 6.X: yum install uwsgi)

pip install uwsgi

 

create test.py

# test.py
def application(env, start_response):
    start_response(200 OK, [(Content-Type,text/html)])
    return [b"Hello World"] # python3
    #return ["Hello World"] # python2

 

run uwsgi

uwsgi --http :8000 --wsgi-file test.py

技术分享

 

now test django project

python manage.py runserver 0.0.0.0:8000

and

uwsgi --http :8000 --module mysite.wsgi

都能显示: It worked

技术分享

 

  • 对接nginx

yum install nginx
systemctl start nginx.service

拷贝文件到你的项目中

https://github.com/nginx/nginx/blob/master/conf/uwsgi_params

 

 

 

 

 

 

 

文档:http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html#configure-nginx-for-your-site

django 1.9 wsgi + nginx

标签:

原文地址:http://www.cnblogs.com/zhaogaolong/p/5257885.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!