uwsgi+nginx+web.py備忘

  1. app.py
app.add_processor(web.loadhook(session_hook))
application = app.wsgifunc() #uwsgi server
  1. uwsgi, uwsgi9090.ini
socket = 127.0.0.1:9090
master = true
vhost = true         
no-stie = true
workers = 32
reload-mercy = 10
vacuum = true
max-requests = 100000
limit-as = 512
listen=10240
buffer-sizi = 65535
pidfile = /tmp/uwsgi9090.pid
daemonize = /var/log/nginx/uwsgi9090.log
stats = 127.0.0.1:1733
disable-logging = 1
  1. nginx, app.conf
server {
    listen       3721;
    server_name  localhost;

    charset utf-8;
    access_log  /var/log/nginx/myapp.access.log  main;

    location / {
            include  /etc/nginx/uwsgi_params;
            uwsgi_pass  127.0.0.1:9090;              
            uwsgi_param UWSGI_SCRIPT app;
            uwsgi_param UWSGI_CHDIR /home/www/myapp;    
     }
   location /static/ {
            root /home/www/myapp;
            if (-f $request_filename) {
               rewrite ^/static/(.*)$  /static/$1 break;
            }
}
    location ~ /\.ht {
        deny  all;
    }
}
  1. 啓動命令
/usr/bin/uwsgi /etc/uwsgi9090.ini
systemctl start nginx
  1. 注意
修改代碼後,須要重啓uwsgi和nginx才能生效。
  重啓uwsgi,先kill掉進程,而後再執行啓動命令
相關文章
相關標籤/搜索