gpt4 book ai didi

sockets - uwsgi提供权限拒绝错误,即使我将chmod-socket设置为664 : works on one machine but not the other

转载 作者:行者123 更新时间:2023-12-03 11:53:07 28 4
gpt4 key购买 nike

这是我的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"

奇怪的是,我在另一台机器(具有相同的文件)上仍然具有完全相同的设置,并且可以正常工作。我将文件复制粘贴到此新计算机上,现在出现此错误。

因此,我知道这些配置文件在我启动旧机器之前和之前都可以使用,这些文件可以正常工作,而没有权限被拒绝的错误。

我的新机器怎么会出现拒绝权限错误?

编辑:对于它的值(value),我在旧机器上做了 groups,这是输出:
myUser adm cd-rom sudo dip www-data plugdev lpadmin sambashare

当我执行 groups www-data时,这是输出:
www-data: www-data ayman

但是,当我在新机器上执行 groups时, www-data不存在。不知道这是否与问题有关。

最佳答案

在以下几点中,我将指代您的用户和您的组。这些是运行uWSGI服务器的用户和组。组很可能与您的用户名具有相同的名称。

  • 检查哪些用户和组nginx正在运行。即使在同一系统版本上,它也可以是不同的组。这可能取决于您安装nginx服务器的方式。您可以在主要的Nginx配置中检查它。
  • 不要将套接字文件放在用户的主目录中。某些Unix系统会阻止其他用户访问它们。套接字文件的好地方是/run//var/run/(对于某些系统,仅存在其中之一)。如果您不能使用/run//var/run/,也可以使用/tmp/
  • 将nginx用户(从第1点开始)添加到您的组中。其他方法(将您的用户添加到nginx组)也可以,但是有时您必须更改套接字所有权。
  • 更改套接字所有者,以将nginx用户或组与您的用户或组混合使用。例如youruser:www-datanginx:yourgroup。您可以添加以下内容:
    chown-socket = youruser:www-data

    到您的uWSGI配置。

  • 满足这些要点将永久解决您的权限问题。

    关于sockets - uwsgi提供权限拒绝错误,即使我将chmod-socket设置为664 : works on one machine but not the other,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35779026/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com