NGINX UWSGI 权限被拒绝

问题描述 投票:0回答:1

使用

  • Ubuntu 20.04
  • Python 3.8.10
  • 不使用virtualenv。一切都已全局安装。

我正在尝试使用 uwsginginx 在我的 VPS 上部署 Django 网站,但我不断收到 502 错误代码。在 nginx error.log 文件中,我有以下异常:

*543 connect() to unix:/root/uwsgi/testproject.sock failed (13: Permission denied) while connecting to upstream

项目结构如下:

wsgi 文件:root/html/testproject/testproject/wsgi.py

uwsgi ini:根/uwsgi/sites/testproject.ini

套接字:root/uwsgi/testproject.sock

注意:我在整个设置过程中使用了root用户。

测试项目.ini

[uwsgi]
chdir=/root/html/testproject
wsgi-file=/root/html/testproject/testproject/wsgi.py
socket=/root/uwsgi/testproject.sock
chmod-socket=666
uid=www-data
gid=www-data

master=True
pidfile=/tmp/project-master.pid
vaccum=True
max-requests=5000
daemonize=/tmp/uwsgi.logs

/etc/nginx/sites-available/testproject

server{
        listen 80;
        server_name 85.31.237.228;

        location / {
                include uwsgi_params;
                uwsgi_pass unix:/root/uwsgi/testproject.sock;
        }
}

有人可以帮我找出我做错了什么吗?

我已经在 666 和 644 之间切换了 chmod 参数,但没有任何效果。

django ubuntu nginx uwsgi
1个回答
0
投票

尝试

ls /root/uwsgi/testproject.sock
查看套接字是否已创建。 运行
ls -l /root/uwsgi/
检查谁拥有 .sock 文件。 运行
ls -l /root/
查看谁拥有 uwsgi 并确保 www-data 用户有权访问 .sock 文件。你可以尝试以 root 身份运行 uwsgi config 然后看看是否可以工作

© www.soinside.com 2019 - 2024. All rights reserved.