Permission denied - nginx and uwsgi socket

前端 未结 9 1750
暗喜
暗喜 2020-12-07 17:44

Well I am currently trying to get my django application served using nginx and uwsgi. I am currently using a virtual environment to which uwsgi is installed. However I am cu

相关标签:
9条回答
  • 2020-12-07 18:14

    This is take me a lot of time to find the problem with permissions. And the problem is with permissions of course. Default user is nginx. What i did: in /etc/nginx/nginx.conf change user:

    user  www-data;
    

    Next join your user to www-data goup:

    usermod -a -G www-data yourusername
    

    Next set uwsgi:

    [uwsgi]
    uid = yourusername
    gid = www-data
    chmod-socket = 660
    

    And then restart nginx:

    sudo systemctl restart nginx
    

    And finaly restart uwsgi.

    0 讨论(0)
  • 2020-12-07 18:15

    This issue made me crazy. My environment is centos7+nginx+uwsgi, using unix socket connection. The accepted answer is awesome, just add some points in there.

    ROOT USER, QUICK TEST

    First, turn off selinux, then change chmod-socket to 666, and finally start uwsgi using root.

    Like this

    setenforce 0 #turn off selinux
    chmod-socket = 666
    uwsgi --ini uwsgi.ini
    

    OTHER USER

    If you use the other user you created to start uwsgi, make sure that the permissions of the user folder under the home folder are 755, and that the owner and the group are corresponding.

    For example

    chmod-socket = 666
    usermod -a -G nginx webuser #add webuser to nginx's group
    cd /home/
    chmod -R 755 webuser
    chown -R webuser:webuser webuser
    uwsgi --ini uwsgi.ini --gid webuser --uid webuser
    
    0 讨论(0)
  • 2020-12-07 18:19

    On CentOS, I tried all those things but still it did not work. Finally, I found this article:

    https://www.nginx.com/blog/nginx-se-linux-changes-upgrading-rhel-6-6/

    For a development machine, we simply run:

    semanage permissive -a httpd_t
    

    But for a real production server, I have not figured out. You may need to try other things described in the above article.

    0 讨论(0)
提交回复
热议问题