目前我正在尝试使用nginx和uwsgi提供django应用程序服务。我目前正在使用虚拟环境安装了uwsgi。然而,当我尝试访问页面时,目前出现502错误网关。
我遇到的错误。
2014/02/27 14:20:48 [crit] 29947#0: *20 connect() to unix:///tmp/uwsgi.sock failed (13: Permission denied) while connecting to upstream, client: 144.136.65.176, server: domainname.com.au, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "www.domainname.com.au"
这是我的nginx.conf文件
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:///tmp/uwsgi.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 .domainname.com.au; # 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 /home/deepc/media; # your Django project's media files - amend as required
}
location /static {
alias /home/deepc/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 /home/deepc/.virtualenvs/dcwebproj/dcweb/uwsgi_params; # the uwsgi_params file you installed
}
}
这是我的uwsgi.ini文件
[uwsgi]
socket=/tmp/uwsgi.sock
chmod-socket=644
uid = www-data
gid = www-data
chdir=/home/deepc/.virtualenvs/dcwebproj/dcweb
module=dcweb.wsgi:application
pidfile=/home/deepc/.virtualenvs/dcwebproj/dcweb.pid
vacuum=true
根据我在 Google 上的阅读,这似乎是与 www-data 组和 /tmp/ 目录的权限问题有关。然而,我对此还很陌生,并尝试更改文件夹的权限级别,但无济于事。请问是否有人可以指点一下方向?这是权限问题吗?另外,将 sock 文件放在 tmp 目录中是否可行?
谢谢。
chmod-socket=644
更改为 666?我不确定。 - Hungerusermod -g www-data username
。希望有所帮助。 - Jiangshi Fresh