I’m trying to deploy my django site to ubuntu server nginx by following this tutorial (https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu).
Deployment works, but css not working. I figured it’s something with collectstatic but not sure. Funny enough css worked properly for 0.0.0.0:8000 port.
This is from settings.py
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
I noticed in tutorial that they don’t have STATICFILES_DIRS… and… STATIC_URL and STATIC_ROOT are same 'static'
. Could this be an issue…?
also, tried editing path to static with sudo nano /etc/nginx/sites-available/django_project
server {
listen 80;
server_name xxx.xx.xx.xxx; #my ip, just hide it for purpose of question
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /home/muser/django_project/static/;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
Any idea what I did wrong? Thanks in advance!