I am new in deploy projects my static files not serving with nginx.
thats look my site-available/myprject file
server{
listen 80;
server_name mydomain;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
autoindex on;
alias /home/user/project/static;
}
location /media/ {
autoindex on;
alias /home/user/project/media;
}
location / {
proxy_pass myIp:myPort;
}
}
My static files and media have this path:
/home/user/project/staict files and media files
that’s how it looks my settings.py configurations
STATIC_URL = '/static/'
STATIC_ROOT =os.path.join(BASE_DIR,'static')
my debug variable is false
I run collectstatic.
2
Answers
I solved the problem this way:
First you have to add in youre urlpatterns in urls.py
create dir in /var/www/html/static
sudo chmod -R 777 /var/www/html/static
Run collectstatic
set your location in sites-available/project (you nginx config)
Here is what I see that this different from my working Django site: