2017-03-29 3 views
0

Ich benutze Django 1.10 + uWsgi + nginx. In Prod Modus der statischen Dateien nicht auftauchen, ist das, was mir meine nginx Fehler-Log sagt:Django - statische/CACHE-Dateien nicht gefunden

404 ... static/CACHE/js/e3a6fa7588d1.js" failed (2: No such file or directory), 

Der Ordner static/CACHE leer bleibt (so den Sinn der 404), aber warum? Ich habe die Berechtigungen bereits auf 775 für static/CACHE festgelegt.

nginx conf:

# /etc/nginx/sites/available/mysite_nginx.conf 
# the upstream component nginx needs to connect to 
upstream bdjango { 
    server unix:///tmp/mysite.sock; # for a file socket 
} 
# configuration of the server 
server { 
    # the port your site will be served on 
    listen 80; 

    # the domain name it will serve for 
    server_name dev.mysite.com; # substitute your machine's IP address or FQDN 
    charset utf-8; 

    # max upload size 
    client_max_body_size 8M; # adjust to taste 

    # Django media 
    location /media { 
     alias /var/www/mysite/src/media; # your Django project's media files - amend as required 
    } 
    location /static { 
     alias /var/www/mysite/src/static; # your Django project's static files - amend as required 
    } 
    # Finally, send all non-media requests to the Django server. 
    location/{ 
     uwsgi_pass adjango; 
     include /var/www/mysite/src/uwsgi_params; # the uwsgi_params file you installed 
    } 
} 

Einstellungen Django enthält

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__) + "../../../") 
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') 

Also, warum meine js/css sind Dateien nicht in static/CACHE?

EDIT: es gelöst: uwsgi_pass wurde an der falschen Stelle stromaufwärts zeigt (die eine andere Website zufällig): uwsgi_pass adjango;

Antwort

1

Es könnte sein, dass django-compressor ausfällt.

Haben Sie versucht, DEBUG = True und COMPRESS_ENABLED = True in Ihren Einstellungen und sehen, ob es funktioniert?

https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED

Alternativ schlage ich vor, mit ADMINS Setup in der Produktion, so dass es E-Mails Sie irgendwelche Fehler oder Setup sentry in Ihrer Produktion Setup.

+0

habe ich schon. Die Dateien sind Kopien der '/ static', jedoch sucht sie nach den (verkleinerten) Dateien in' static/CACHE', die leer sind. – FeedTheWeb

+0

Ist das "Django-Kompressor"? – user73657

+0

Ja ist es. aber es scheint nicht die Dateien zu erstellen. – FeedTheWeb

1
  1. Verwenden Sie CACHE?
  2. Haben Sie STATIC_URL und STATIC_ROOT korrekt festgelegt?
  3. Ist DEBUG = False?
  4. Verwenden Sie ein Drittanbieter-Tool, um Ihre statischen Dateien zu cachen/pipline?