uwsgi nginx连接到unix套接字被拒绝
我想从Ubuntu 14.04迁移django应用程序到raspberry pi(raspbian os) 对于Ubuntu我已经完成http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html,它工作。uwsgi nginx连接到unix套接字被拒绝
在raspbian中并不那么简单。
这是我在/ etc/nginx的/启用的站点 -
bills_nginx.conf # the upstream component nginx needs to connect to
upstream django {
server unix:/var/www/html/bills/bills/bills.sock; # for a file socket
#server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name 192.168.5.5; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /var/www/html/bills/bills/bills/media; # your Django project's media files - amend as required
}
location /static {
alias /var/www/html/bills/bills/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location/{
uwsgi_pass django;
include /var/www/html/bills/bills/uwsgi_params; # the uwsgi_params file you installed
}
}
bills_nginx.conf,这是我UWSGI INI文件:
[uwsgi] # Django-related settings
# the base directory (full path)
chdir = /var/www/html/bills/bills
# Django's wsgi file
module = bills.wsgi
# the virtualenv (full path)
home = /home/seb/.virtualenvs/bills3
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket = /var/www/html/bills/bills/bills.sock
# ... with appropriate permissions - may be needed
uid =www-data
gid=www-data
chown-socket=www-data:www-data
chmod-socket = 666
# clear environment on exit
vacuum = true
daemonize=/var/log/uwsgi/bills3.log
error_log=/var/log/nginx/bills3_error.log
在error.log中我得到:
2017/03/08 10:27:43 [error] 654#0: *1 connect() to unix:/var/www/html/bills/bills/bills.sock failed (111: Connection refused) while connecting to upstream, client: 192.168.5.2, server: 192.168.5.5, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/var/www/html/bills/bills/bills.sock:", host: "192.168.5.5:8000"
请帮我搞定:)
回答:
CHMOD插槽,CHOWN插槽,GID,UID,插座对于uWSGI和nginx的要通过套接字通信,您需要指定的权限和插座的所有者。 777由于chmod-socket对于生产太自由了。然而,你可能不得不乱用这个数字来使它正确,所以一切必要的可以沟通。如果你不把你的插槽配置的照顾,你会得到错误,如:
所以一定要确保该文件夹的权限.. 我认为更好的办法
$ sudo mkdir /var/uwsgi $ sudo chown www-data:www-data /var/uwsgi
And change the socket path
upstream django {
server unix:/var/uwsgi/bills.sock; # for a file socket
#server 127.0.0.1:8001; # for a web port socket (we'll use this first) }
更多参考:请检查一个伟大的文章 http://monicalent.com/blog/2013/12/06/set-up-nginx-and-uwsgi/
而且我之前有同样的问题可能你可以检查我的配置过于
nginx django uwsgi page not found error
以上是 uwsgi nginx连接到unix套接字被拒绝 的全部内容, 来源链接: utcz.com/qa/263159.html