这是我的mysite_uwsgi.ini
文件:
# mysite_uwsgi.ini file
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /home/user/Documents/CMS
# Django's wsgi file
module = CMS.wsgi
# the virtualenv (full path)
home = /home/user/.virtualenvs/CMS
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket = /home/user/Documents/mysite/mysite.sock
# ... with appropriate permissions - may be needed
chmod-socket = 664
# clear environment on exit
vacuum = true
这是我的mysite_nginx.conf
文件:
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:///home/user/Documents/mysite/mysite.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 8000;
# the domain name it will serve for
server_name 192.168.174.169; # 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/user/Documents/media; # your Django project's media files - amend as required
}
location /static {
alias /home/user/Documents/mysite/mysiteapp/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/user/Documents/mysite/mysite/uwsgi_params; # the uwsgi_params file you installed
}
}
现在我跑这个:
uwsgi --ini mysite_uwsgi.ini
我收到此错误:
2016/03/03 12:23:26 [crit] 6232#0: *1 connect() to unix:///home/user/Documents/mysite/mysite.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: 192.168.174.169, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///home/user/Documents/mysite/mysite.sock:", host: "127.0.0.1:8000"
奇怪的是,我已经并且仍然在不同的机器上使用相同的设置(具有相同的文件),并且它可以工作。我复制粘贴文件到这台新机器,现在它给出了这个错误。
所以我知道这些配置文件在我启动旧机器之前和之后都有效,这些文件完美无误,没有权限被拒绝。
为什么我的新机器会出现权限被拒绝错误?
编辑:为了它的价值,我在我的旧机器中做了groups
,这是输出:
myUser adm cd-rom sudo dip www-data plugdev lpadmin sambashare
当我做groups www-data
时,这就是输出:
www-data: www-data ayman
但是,当我在新计算机上执行groups
时,www-data
不存在。不确定这是否与此问题有关。
答案 0 :(得分:2)
在下面的点中,我将引用您的用户和您的群组。这些是运行uWSGI服务器的用户和组。最有可能的是,群组的名称与您的用户名相同。
/run/
或/var/run/
(对于某些系统,只有其中一个存在)。如果您无法使用/run/
和/var/run/
,则还可以使用/tmp/
。 更改套接字所有者以将nginx用户或群组与您的用户或群组混合。例如youruser:www-data
或nginx:yourgroup
。您可以通过添加:
chown-socket = youruser:www-data
到您的uWSGI配置。
实现这些要点应该永久性地解决您的问题。