Skip to content

Serving static files #7

@eddo87

Description

@eddo87

Hi there,

this is more a newbie question but after many hours spent troubleshooting, and found many un resolved questions on StackOverflow I thought I might ask!

First of all props for the project, as it's very useful for someone that wants to start on django!

On the Sys admin side, as I would like to have a production website in the future and I'm testing it.

Why while serving the website through Nginx and uWSGI, pointing to the static correctly
I still see a "broken" (of css and js) site?

at first I had the nginx config wrong, now I get no errors but still can't see the website properly.

Do I have to delete local.py and just keep default.py?
are there any specific permissions to be added?
Everything is run and owned by www-data, socket permissions on 774
Thanks a lot!

here some info of the setup

manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:
/home/django/sample/static

root@bananapi /home/django # tree -d sample
sample
├── media
├── sample
│   ├── home
│   └── settings
├── static
│   ├── admin
│   │   ├── css
│   │   ├── img
│   │   │   └── gis
│   │   └── js
│   │   └── admin
│   ├── CACHE
│   │   ├── css
│   │   └── js
│   ├── css
│   ├── django_extensions
│   │   ├── css
│   │   ├── img
│   │   └── js
│   ├── images
│   ├── js
│   ├── libs
│   │   ├── bootstrap-3.3.5
│   │   │   ├── css
│   │   │   ├── fonts
│   │   │   └── js
│   │   ├── font-awesome-4.3.0
│   │   │   ├── css
│   │   │   ├── fonts
│   │   │   ├── less
│   │   │   └── scss
│   │   ├── jquery
│   │   │   └── 2.1.0
│   │   └── modernizr
│   │   └── 2.6.2
│   └── media
├── static-assets
│   ├── css
│   ├── images
│   ├── js
│   ├── libs
│   │   ├── bootstrap-3.3.5
│   │   │   ├── css
│   │   │   ├── fonts
│   │   │   └── js
│   │   ├── font-awesome-4.3.0
│   │   │   ├── css
│   │   │   ├── fonts
│   │   │   ├── less
│   │   │   └── scss
│   │   ├── jquery
│   │   │   └── 2.1.0
│   │   └── modernizr
│   │   └── 2.6.2
│   └── media -> ../media/
└── templates

nginx.conf

upstream sample {
server unix:/home/django/sample/sample.sock;
}

server {
listen 80;
server_name bananapi;
access_log off;

    location /static/ {
       alias /home/django/sample/static/;
    }

    location /media/ {
       alias /home/django/sample/media/;
    }

    location / {
       root /home/django/sample;
       uwsgi_pass   sample;
       include /etc/nginx/uwsgi_params;
       uwsgi_send_timeout 300;
       uwsgi_read_timeout 300;
       proxy_pass http://unix:/home/django/sample/sample.sock;
       proxy_set_header Host $host;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions