[Django] deploy with fastcgi
The django official team has begun to deploy the django application with fastcgi. As a user who has used it before, I should post a configuration to commemorate it.
Under Project
#! /bin/shcase "$@" in start) python manage.py runfcgi host=127.0.0.1 port=8400 ;; stop) kill -9 `ps aux|grep runfcgi|grep 8400|awk '{print $2}'|xargs` ;; restart) kill -9 `ps aux|grep runfcgi|grep 8400|awk '{print $2}'|xargs` sleep 1 python manage.py runfcgi host=127.0.0.1 port=8400 ;; *) echo 'unknown arguments' exit 1 ;;esac
Nginx Configuration
server { listen 80; server_name 127.0.0.1; access_log /var/log/nginx/vsite.access_log; error_log /var/log/nginx/vsite.error_log; location ^~/media { alias /data/test/vsite/staticfiles; } location ^~/upload { alias /data/test/vsite/uploadfiles; } location ^~/static { alias /data/test/vsite/staticfiles; } location / { # host and port to fastcgi server fastcgi_pass 127.0.0.1:8401; 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_pass_header Authorization; fastcgi_intercept_errors off; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_param SERVER_PROTOCOL $server_protocol; }}