django 1.9 wsgi + nginx

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

技术分享

 

now test django project

python manage.py runserver 0.0.0.0:8000

and

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

都能显示: It worked

技术分享

 

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的主要内容,如果未能解决你的问题,请参考以下文章