I saw many questions about SO on this topic, and I tried as many methods as I could, but it still does not solve the problem for me, so I hope this post can be useful.
I follow the guide of this site to configure Django on Nginx with uWSGI: http://www.oliverelliott.org/article/computing/tut_setup_nginx_django/
Uwsgi.ini file
[uwsgi] chdir=/home/ec2-user/project/awssite module=awssite.wsgi home=/home/ec2-user/project master=true processes=2 socket=/home/ec2-user/project/awssite/awssite.socket chmod-socket=666 vacuum=true
etc. / Nginx / sites with support / awssite _nginx.conf
upstream django { server unix:///home/ec2-user/project/awssite/awssite.socket; } server { listen 8080; server_name localhost; charset utf-8;
This is the error code in /var/log/nginx/error.log
2016/02/15 01:21:22 [crit] 22159#0: *3 connect() to unix:///home/ec2-user/project/awssite/awssite.socket failed (13: Permission denied) while connecting to upstream, client: CLIENT_IP, server: localhost, request: "GET /menu/ HTTP/1.1", upstream: "uwsgi://unix:///home/ec2-user/project/awssite/awssite.socket:", host: "HOST_IP:8080"
Note. CLIENT_IP and HOST_IP are IP address values.
This is what I tried and did not work :
chmod 755 home directory and working uwsgi --socket awssite.socket --module awssite.wsgi --chmod-socket=666
2. Adding the nginx user to my user group and starting uwsgi --socket awssite.socket --module awssite.wsgi --chmod-socket=664
3. modify the ini file by adding these new lines
chown-socket=ec2-user:nginx uid=nginx gid=nginx , and then run uwsgi --ini uwsgi.ini . This returns with "Permission denied for chown", but when I run the command with sudo , I get sudo: uwsgi: command not found (uWSGI is set to system-wide)
4. Put all the files in a different directory (outside the ec2-user ), but this does not allow me to access them if I did not run it as root , and even then it does not work.
5. launch uwsgi --socket awssite.socket --module awssite.wsgi --chmod-socket=664/666 --uid nginx with options --uid nginx --gid nginx --chown-socket=nginx:nginx Note: 664/666 means that I tried both permissions
6. Renamed the nginx.conf.default and nginx.conf.rpmnew files (so the only conf file for reading nginx is nginx.conf )
Can anyone shed some light on how I can solve this problem? I will continue to add the methods that I tried and did not work on this issue while I work on it. Thanks:)
EDIT: Thanks to @GwynBleidD's answer, I finally got it working. This is what works:
saved my socket file to /tmp
etc. / Nginx / sites with support / awssite _nginx.conf
upstream django { server unix:///tmp/djangosocket/awssite.socket; } ....
Uwsgi.ini file
[uwsgi] chdir=/home/ec2-user/project/awssite module=awssite.wsgi home=/home/ec2-user/project master=true processes=2 socket=/tmp/djangosocket/awssite.socket chmod-socket=666 vacuum=true
I added my ec2-user (registered user) to the nginx group.
I changed the file permissions accordingly chown -R ec2-user:nginx djangosocket
chmod g+rwx djangosocket