python - Django - Apache with mod_wsgi not serving static-files -


i'm using apache mod_wsgi serve project , it's static-files.

i used offical docs "how use django apache , mod_wsgi" , works fine, except static files not found. haven't found way debug problem, or specific message point me error.

what did far:

  • double checked static-files places correctly in static-files directory. collected collectstatic
  • checked file permissions

settings.py:

[..] debug = false static_root = '/var/www/djangoproject/static-files' static_url = '/static/' 

apache settings:

wsgidaemonprocess djangoproject  wsgiprocessgroup djangoprojectgroup wsgiapplicationgroup %{global}  wsgipythonhome /var/www/djangoproject/venv/lib/python2.7/site-packages wsgipythonpath /var/www/djangoproject/  wsgiscriptalias / /var/www/djangoproject/djangoproject/wsgi.py <directory /var/www/djangoproject/djangoproject>     <files wsgi.py>         require granted     </files> </directory>  alias /static/ /var/www/djangoproject/static-files/ <directory  /var/www/djangoproject/static-files>     require granted </directory> 

wsgi.py

import os, sys  sys.path.append('/var/www/djangoproject') sys.path.append('/var/www/djangoproject/venv/lib/python2.7/site-packages')  os.environ.setdefault("django_settings_module", "djangoproject.settings")  django.core.wsgi import get_wsgi_application application = get_wsgi_application() 

apache access log:

"get /static/app01/css/default.css http/1.1" 404 346 "http://example.com/" 

apache2.conf:

mutex file:${apache_lock_dir} default  pidfile ${apache_pid_file}  timeout 300 keepalive on maxkeepaliverequests 100 keepalivetimeout 5  user ${apache_run_user} group ${apache_run_group}  hostnamelookups off  errorlog ${apache_log_dir}/error.log loglevel warn  includeoptional mods-enabled/*.load includeoptional mods-enabled/*.conf  include ports.conf  <directory />         options followsymlinks         allowoverride none         require denied </directory>  <directory /usr/share>         allowoverride none         require granted </directory>  <directory /var/www/>         options indexes followsymlinks         allowoverride none         require granted </directory>  accessfilename .htaccess  <filesmatch "^\.ht">         require denied </filesmatch>  logformat "%v:%p %h %l %u %t \"%r\" %>s %o \"%{referer}i\" \"%{user-agent}i\"" vhost_combined logformat "%h %l %u %t \"%r\" %>s %o \"%{referer}i\" \"%{user-agent}i\"" combined  logformat "%h %l %u %t \"%r\" %>s %o" common logformat "%{referer}i -> %u" referer logformat "%{user-agent}i" agent  includeoptional conf-enabled/*.conf includeoptional sites-enabled/ 

i found great answer "serving static files mod_wsgi , django".

  • the order relevant, alias static files must in first place.

apache settings:

wsgidaemonprocess djangoproject  wsgiprocessgroup djangoprojectgroup wsgiapplicationgroup %{global}  wsgipythonhome /var/www/djangoproject/venv/lib/python2.7/site-packages wsgipythonpath /var/www/djangoproject/  alias /static/ /var/www/djangoproject/static-files/ <directory /var/www/djangoproject/static-files>     require granted </directory>  wsgiscriptalias / /var/www/djangoproject/djangoproject/wsgi.py <directory /var/www/djangoproject/djangoproject>     <files wsgi.py>         require granted     </files> </directory> 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -