python manage.py runfcgi socket=/tmp/python/python.sock maxrequests=1
当然也可以
#python manage.py runfcgi method=prefork host=127.0.0.1 port=9001
server {
listen 80;
root /Users/sundebiao/myfile/workspace/mysite;
index index.html index.htm index.py;
server_name mysite.cc;
access_log /var/log/mysite/django.access.log;
location ~* ^/media/(css|img|js)/.*$ {
root /Library/Python/2.7/site-packages/django/contrib/admin;
expires 30d;
break;
}
location ~* ^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg)$ {
access_log off;
break;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|bmp|js)$ {
expires 30d;
break;
}
location / {
fastcgi_pass unix:/tmp/python/python.sock;
#如果上面是采用TCP的形式则
#fastcgi_pass 127.0.0.1:9001;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_SOFTWARE "nginx";
fastcgi_param GATEWAY_INTERFACE "CGI/1.1";
}
}
如果出现502错误的话,看一下python.sock的权限