Errno 13 Permission denied using Gunicorn

前端 未结 4 1469
南笙
南笙 2020-12-11 04:04

I\'m running django on Digital Ocean with gunicorn and nginx. Gunicorn for serving the django and nginx for static files.

Upon upl

4条回答
  •  感情败类
    2020-12-11 04:34

    Well, I worked on this issue for more than a week and finally was able to FIGURE IT OUT. Please follow links from digital ocean , but they did not pinpoint important issues one which includes

    1. no live upstreams while connecting to upstream
    2. *4 connect() to unix:/myproject.sock failed (13: Permission denied) while connecting to upstream
    3. gunicorn OSError: [Errno 1] Operation not permitted
    4. *1 connect() to unix:/tmp/myproject.sock failed (2: No such file or directory)

      etc.

    These issues are basically permission issue for connection between Nginx and Gunicorn. To make things simple, I recommend to give same nginx permission to every file/project/python program you create.

    To solve all the issue follow this approach: First thing is :

    1. Log in to the system as a root user
    2. Create /home/nginx directory.
    3. After doing this, follow as per the website until Create an Upstart Script.
    4. Run chown -R nginx:nginx /home/nginx
    5. For upstart script, do the following change in the last line : exec gunicorn --workers 3 --bind unix:myproject.sock -u nginx -g nginx wsgi DONT ADD -m permission as it messes up the socket. From the documentation of Gunicorn, when -m is default, python will figure out the best permission
    6. Start the upstart script
    7. Now just go to /etc/nginx/nginx.conf file. Go to the server module and append:

      location / { include proxy_params; proxy_pass http<>:<>//unix:/home/nginx/myproject.sock; } REMOVE <> Do not follow the digitalocean aricle from here on

      1. Now restart nginx server and you are good to go.

提交回复
热议问题