您的位置:首页 > 运维架构 > Nginx

nginx+gunicorn运行django

2012-07-26 15:01 267 查看
运行django的有fast_cgi、uwsgi和gunicorn等 其中uwsgi效能最好 但配置稍复杂 而gunicorn配置简单

在windows下通过源码安装gunicorn报错 缺少fcntl模块 最好在linux环境下使用

首先安装gunicorn 和django

gunicorn_django -D -b 127.0.0.1:8000

然后配下nginx

server {

listen 80;

server_name 域名;

root django项目目录 ;

location /static/ {

if ($query_string) {

expires max;

# log_not_found off;

}

}

location / {

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header Host $http_host;

proxy_redirect off;

if (!-f $request_filename) {

proxy_pass http://127.0.0.1:8000;
break;

}

}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /media/50x.html;

}

参考网站(http://gunicorn.org/, )
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: