配置 nginx django gunicorn

推荐看这篇  http://senko.net/en/django-nginx-gunicorn/

因为fastcgi不知道为何老是自己会生成新进程导致504

虽然网站流量不大但还是把这淘汰的东西换了吧。

同事说gunicorn部署很方便 就试了下,果然没几下就配好了

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;

        }

红色的地方换下

蓝色的地方一致就好了。

猜你喜欢

转载自pako.iteye.com/blog/1568794