After settings nginx in server static has disappeared from the site.
If you work only with gunicorn, all everything is successful.
Command "python manage.py collectstatic " executed :
440 static files copied to ‘/home/v_n_kich/Project_LAWboard/static’.
settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
sudo nano /etc/nginx/sites-enabled/default
server {
listen 80;
listen 51.250.71.28;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/v_n_kich/Project_LAWboard/;
}
location /media/ {
root /home/v_n_kich/Project_LAWboard/;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
urls.py
urlpatterns += static(settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL,
document_root=settings.STATIC_ROOT)
sudo less /var/log/nginx/error.log:
2023/02/20 22:59:11 [error] 861#861: *14 open() "/home/v_n_kich/Project_LAWboard/static/bootstrap/dist/js/bootstrap.min.js" failed (13: Permission denied), client:
178.71.105.162, server: , request: "GET /static/bootstrap/dist/js/bootstrap.min.js HTTP/1.1", host: "51.250.71.28", referrer: "http://51.250.71.28/auth/signup/
2
Answers
Decided
the problem was indeed permissions
I added users 'www-data' to groups
sudo gpasswd -a www-data 'my groupd'
and
sudo systemctl restart nginx
Your problem appears to be with permissions. On your /etc/nginx/nginx.conf you can add group and user to nginx:
And on the cache dir, set permissions to correspond with USER GROUP:
And if necessary, change /DIR permissions to 755