码迷,mamicode.com
首页 > 其他好文 > 详细

django + nginx + uwsgi

时间:2018-09-15 20:49:27      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:chm   user   location   ini   ica   压缩   启用   java   span   

    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的配置文件

django + nginx + uwsgi

标签:chm   user   location   ini   ica   压缩   启用   java   span   

原文地址:https://www.cnblogs.com/jeroen/p/9652017.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!