django 1.9 wsgi + nginx

  • 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

image

 

now test django project

python manage.py runserver 0.0.0.0:8000

and

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

都能显示: It worked

image

 

  • 对接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

posted @ 2016-03-09 13:48  zhaogaolong  阅读(268)  评论(0)    收藏  举报