在前面的文章使用xml的方式配置的uwsgi容器,但是xml方式可以配置的参数较少,而且配置比较老,现在修改成为使用ini方式配置
配置文件如下:
[uwsgi]
chdir = /opt/destiny/destiny-core
home = /opt/destiny/destinyenv
module = destiny.wsgi:application
#wsgi-file = /opt/destiny/destiny-core/django_uwsgi.py
master = true
processes = 2
enable-threads = true
# use unix socket because it is more secure and faster than TCP socket
socket = %(chdir)/uwsgi/uwsgi-destiny.sock
status = %(chdir)/uwsgi/uwsgi-destiny.status
pidfile = %(chdir)/uwsgi/uwsgi-destiny.pid
daemonize = %(chdir)/uwsgi/uwsgi.log
chmod-socket = 662
vacuum = true
die-on-term = true
logto = %(chdir)/uwsgi/uwsgi-destiny.log
env = LANG=en_US.UTF-8
env = LC_ALL=en_US.UTF-8
env = PYTHONIOENCODING=UTF-8
# 如果不加最后两行会报错 UnicodeEncodeError: 'ascii' codec can't encode character
nginx配置如下
server {
listen 80;
listen 443 ssl;
charset utf-8;
server_name destiny.wonderfultop.com;
access_log /var/log/nginx/destiny/access.log;
error_log /var/log/nginx/destiny/error.log;
proxy_http_version 1.1;
proxy_set_header Connection "";
ssl on;
ssl_certificate /opt/destiny/config/Nginx/*.crt;
ssl_certificate_key /opt/destiny/config/Nginx/*.key;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
include uwsgi_params;
uwsgi_pass_request_body on;
uwsgi_pass_request_headers on;
uwsgi_pass unix:/opt/destiny/destiny-core/uwsgi/uwsgi-destiny.sock;
uwsgi_read_timeout 1800;
uwsgi_send_timeout 300;
proxy_connect_timeout 600;
proxy_read_timeout 600;
sendfile on;
client_max_body_size 20M;
keepalive_timeout 0;
}
location /static/ {
alias /opt/destiny/destiny-core/static/;
}
}
#启动
uwsgi --ini uwsgi_destiny.ini
#退出
kill