Unable to load staticfiles after deploying django app on aws-ec2

by VINEET SHARMA   Last Updated August 14, 2019 18:26 PM

I am a beginner in aws and I am trying to deploy a django app on aws-ec2. I have set-up gunicorn application server and nginx web server and app loads but without static files. I have followed many answers on stackoverflow but I am unable to fix my problem.

I tried with both root and alias but they didn't work. The project structure is as follows:- /home/ubuntu/myskillhut/

django.conf(nginx configuration file)

server {
        ...

        location / {
                include proxy_params;
                proxy_pass http://unix:/home/ubuntu/myskillhut/app.sock;
        }

        location /static/ {
                autoindex on;
                alias /home/ubuntu/myskillhut/static/;
        }
}

settings.py

...
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static/"), )
...


Related Questions



Doesn't Nginx support Django admin static files

Updated November 11, 2017 03:26 AM