看来网上的大篇教程,总结一下配置所遇到坑
- 关于nginx配置+uwsgi配置问题
uwsgi
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /home/ubuntu/access_app/access_server
# Django's wsgi file
wsgi-file = uwsgi.ini
module = access_server.wsgi
# the virtualenv (full path)
# home = /path/to/virtualenv
max-requests = 2000
# process-related settings
threads=2
master = true
# maximum number of worker processes
processes = 2
# the socket (use the full path to be safe
#socket = /home/ubuntu/access_app/access_server/mysite.sock
# ... with appropriate permissions - may be needed
# chmod-socket = 664
# clear environment on exit
vacuum = true
# socket = 0.0.0.0:9999
daemonize = /home/ubuntu/access_app/access_server/uwsgi.log
socket=/var/uwsgi.sock
touch-reload = server.reload
socket这个配置注意需要填的是一个sock文件,用http协议的端口改成 http =0.0.0.0:8000,touch-reload当文件发生改变时自动重启
nginx配置
http {server {
listen 80;
server_name localhost;
location /{
include /etc/nginx/uwsgi_params;
# uwsgi_pass localhost:9999;
uwsgi_pass unix:/var/uwsgi.sock;
}
error_page 500 502 503 504 /50x.html;
location /static{
alias /var/access/;
}
}}
events {
worker_connections 1024; ## Default: 1024
}
nginx配置uwsgi_pass也要修改为对应sock文件
如果用http的话,需要加上
upstream django {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
location位置改为
location / {
uwsgi_pass django;
include /path/to/your/mysite/uwsgi_params;
}
网友评论