如何为Django项目配置nginx和uWSGI

时间:2013-05-11 06:01:39

标签: python django nginx uwsgi

我正在尝试在本地机器上为Django项目配置nginx + uWSGI ..但是nginx和uWSGI没有相互交互..

我已将{nginx配置放在/etc/nginx/sites-available/default中,即:

    upstream django {
    # connect to this socket
    # server unix:///tmp/uwsgi.sock;    # for a file socket
    server 127.0.0.1:8001;      # for a web port socket
    }

server {
    # the port your site will be served on
    listen      4321;
    # the domain name it will serve for
    server_name localhost;   # substitute your machine's IP address or FQDN
    charset     utf-8;

    #Max upload size
    client_max_body_size 75M;   # adjust to taste


    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually
        }
    }

然后我用这个命令启动uWSGI:

uwsgi --socket 127.0.0.1:8001 --chdir /home/vaibhav/TRAC/coupon-rest-api/couponRestApi/ --wsgi-file couponRestApi/wsgi.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191
uWSGI正在工作,但是nginx + uWSGI没有..请告诉我这里我做错了什么......

nginx日志:

2013/05/11 11:12:56 [warn] 6563#0: server name "http://localhost/" has suspicious symbols in /etc/nginx/sites-enabled/default:30
2013/05/11 11:12:56 [emerg] 6563#0: unexpected "}" in /etc/nginx/sites-enabled/default:79
2013/05/11 11:16:01 [emerg] 8352#0: unexpected "}" in /etc/nginx/sites-enabled/default:79

我在nginx配置中发现了错误,但现在当我打开Django管理面板时,布局失真......

1 个答案:

答案 0 :(得分:1)

试试/usr/local/lib/python2.7/sites-packages/django /