Nginx: Permission denied to Gunicorn socket on CentOS 7

会有一股神秘感。 提交于 2019-12-04 12:01:56

If all the permissions under the myproject_app folder are correct, and centos user or nginx group have access to the files, I would say it looks like a Security Enhanced Linux (SELinux) issue.

I had a similar problem, but with RHEL 7. I managed to solve it by executing the following command:

sudo semanage permissive -a httpd_t

It's related to the security policies of SELinux, you have to add the httpd_t to the list of permissive domains.

This post from the NGINX blog may be helpful: NGINX: SELinux Changes when Upgrading to RHEL 6.6 / CentOS 6.6

Motivated by a similar issue, I wrote a tutorial a while ago on How to Deploy a Django Application on RHEL 7. It should be very similar for CentOS 7.

Most probably one of two

1- the directory is not accessible to nginx /home/centos/myproject_app/

$ ls -la /home/centos/myproject_app/

if it is not accessible try to change the path to /etc/nginx if not then try the command

$ /home/centos/myproject_app/django_env/bin/gunicorn --workers 3 --bind unix:/home/centos/myproject_app/django.sock app.wsgi:application

if still not working then activate the environment and python manage.py runserver 0.0.0.0:8000 go to the browser and go to http://ip:8000 the problem may be here, but it the command of gunicorn worked well, then the problem in directory access for nginx user

Exact same problem here.

Removing Group=www-data fixed the issue for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!