Nginx与python web服务配置(Uwsgi& FastCGI)

Uwsgi

  • start uswgi
uwsgi --harakiri 360000 --body-read-warning=10000 --max-fd=65536 -b 1000000 --http-buffer-size=65536 --post-buffering 8192 --post-buffering-bufsize=65536 -p 10 --threads 20 -s 10.10.192.63:8082 -w app:app -d /application/search/log/uws_gi.log 
  • nginx setting
upstream  uwsgi_host {
              server   10.10.192.63:8082;
              server   10.10.192.64:8082;
    }
    #gzip  on;
    server {
            listen 8081;
            server_name localhost;

            location /static {
                    alias /uwsgi/myenv/myproject/static;
            }
            location / {
                    client_max_body_size    61440m;

                    proxy_send_timeout   36000;
                    proxy_read_timeout   36000;
                    proxy_connect_timeout 36000;
                    proxy_buffer_size    512k;
                    proxy_buffers     64 128k;
                    proxy_busy_buffers_size 1024k;
                    proxy_temp_file_write_size 512k;

                    include uwsgi_params;
                    uwsgi_pass uwsgi_host;
            }

            error_page 404 /404.html;
    } 

FastCGI And Django

  • make a django project then run it
python manage.py runfcgi method=prefork host=127.0.0.1 port=9000 pidfile=/var/run/ django.pid
  • nginx setting
server {
    server_name .website.com;
    listen 80;
    root /home/website/www;
    index index.html;

    location / {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        include fastcgi_params;
    }
}
原文地址:https://www.cnblogs.com/nagi/p/4191407.html