django + nginx + uwsgi

    server{                                                                                                    
        listen          80;                                                                                    
        server_name     0.0.0.0;                                                                               
                                                                                                               
        charset utf-8;                                                                                         
        access_log      /var/log/nginx/access.log       main;                                                  
        location / {                                                                                           
                 include uwsgi-params;                                                                         
                 uwsgi_connect_timeout 30;                                                                     
                 uwsgi_pass unix:/home/ubuntu/www/taobaok/script/uwsgi.sock;                                   
                 gzip_types text/plain application/x-javascript text/css text/javascript application/x-httpd-p\
  hp application/json text/json image/jpeg image/gif image/png application/octet-stream; # 支持压缩的类型        
                                                                                                               
        }                                                                                                      
        error_page 500 502 503 504      /50x.html;                                                             
        location = /50x.html {                                                                                 
                 root /usr/share/nginx/html;                                                                   
        }                                                                                                      
    }

以上为nginx.conf中需要配置的服务器, 关键在uwsgi_pass 设置参数

# uwsig使用配置文件启动
[uwsgi]
#http-socket = :8080
#socket = 0.0.0.0:8081
# 项目目录
chdir= /home/ubuntu/www/taobaok
# 指定项目的application
#module=taobaok.wsgi.application
wsgi-file=/home/ubuntu/www/taobaok/taobaok/wsgi.py
# 指定sock的文件路径       
socket=/home/ubuntu/www/taobaok/script/uwsgi.sock
#uwsgi_pass=127.0.0.1:8080;
# 进程个数       
workers=5
pidfile=/home/ubuntu/www/taobaok/script/uwsgi.pid
# 指定IP端口       
http=0.0.0.0:8080
# 指定静态文件
static-map=/static=/home/ubuntu/www/taobaok/taobaok/
# 启动uwsgi的用户名和用户组
uid=ubuntu
gid=users
chmod-socket=666
# 启用主进程
master=true
# 自动移除unix Socket和pid文件当服务停止的时候
vacuum=true
# 序列化接受的内容,如果可能的话
thunder-lock=true
# 启用线程
enable-threads=true
# 设置自中断时间
harakiri=30
#
max-requests = 1000
limit-as = 512
buffer-size=30000

# 设置缓冲
post-buffering=4096
# 设置日志目录
daemonize=/home/ubuntu/www/taobaok/script/uwsgi.log

以上为uwsgi.ini的配置文件

猜你喜欢

转载自www.cnblogs.com/jeroen/p/9652017.html