My Django website will not show CSS or JS using the Django static file management
My html (live version available here)
{% load staticfiles %}
<html>
<head>
<!-- THESE WORK LOCALY BUT DO NOT WORK ON THE SERVER -->
<link rel = "stylesheet" href ="{% static "survey/css/bootstrap.min.css" %}" >
<link rel = "stylesheet" href ="{% static "survey/css/bootstrap.css" %}">
<link rel="stylesheet" href ="{% static "survey/css/jquery-ui.css" %}">
<link rel="stylesheet" href ="{% static "survey/css/slider.css" %}">
<link rel="stylesheet" href="{% static "survey/resources/demos/style.css" %}">
<script src="{% static "survey/js/jquery.min.js" %}"></script>
<script src="{% static "survey/js/jquery-ui.js" %}"></script>
<script src="{% static "survey/js/slider.js" %}"></script>
My settings.py
STATIC_ROOT = '/var/www/bias_experiment/static'
STATIC_URL = '/static/'
My Apache defaults file /etc/apache2/sites-available/defaults
NOTE: I am not able to use a <VirtualHost>
due to the fact that "the server name you are using is the main name of that server" as I found out in another SO question So i have put thsi all in the defaults file.
<VirtualHost *:80>
AliasMatch ^/([^/]*\.css) /var/www/bias_experiment/src/survey/static/$1
Alias /static/ /var/www/bias_experiment/src/survey/static/
<Directory /var/www/bias_experiment/src/survey/static>
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias /bias_experiment /var/www/bias_experiment/src/bias_experiment/index.wsgi
<Directory /var/www/bias_experiment/src/bias_experiment>
<Files index.wsgi>
Order deny,allow
Allow from all
</Files>
</Directory>
....
(other Apache default code here)
....
</VirtualHost>
'django.contrib.staticfiles',
is included in the INSTALLED_APPS- I have set the permissions of the static folder to www-data
- I have run
collectstatic
This is some of the output of `colllectstatic'
....
Copying '/var/www/bias_experiment/src/survey/static/survey/css/jquery-ui.theme.css'
Copying '/var/www/bias_experiment/src/survey/static/survey/css/bootstrap.min.css'
Copying '/var/www/bias_experiment/src/survey/static/survey/css/bootstrap-theme.css'
Copying '/var/www/bias_experiment/src/survey/static/survey/css/slider.css'
36 static files copied, 103 unmodified.
- I have restarted Apache
I am on a shared VM running Apache 2.2.22 and mod_wsgi 3.3-4ubuntu0.1
Yet none of the static files will appear.
Any helps is much appreciated
EDIT 1
As per Stevens suggestion I have updated the static root to
STATIC_ROOT = '/var/www/bias_experiment/src/survey/static/'
But with no luck.
EDIT 2
This is the file permissions for each of the files down to and including one of the CSS files. I believe they are correct?
/var/www/bias_experiment/static/survey/css/bootstrap.css
-rw-r--r-- 1 www-data www-data 121463 Jul 22 19:17 bootstrap.css
/var/www/bias_experiment/static/survey/css
drwxr-xr-x 2 www-data www-data 4096 Jul 22 19:17 css
/var/www/bias_experiment/static/survey
drwxr-xr-x 6 www-data www-data 4096 Jul 18 14:44 survey
/var/www/bias_experiment/static
drwxr-xr-x 10 www-data www-data 4096 Jul 22 19:17 static
EDIT 3 ls -ltr /var/www/bias_experiment/src/survey/static/