title: Django static file 404 errors when deployed with mod_wsgi
body: <p>I am getting 404 errors on all of my static files when I try to deploy them in production</p>
  
  <p><a href="http://phaedrus.scss.tcd.ie/bias_experiment/slide_test/" rel="nofollow noreferrer">A live page of the site is available here</a>. Inspecting the page in Chromes Console or Firebug will show the below issues. </p>
  
  <p><img src="https://i.stack.imgur.com/3v2Ch.png" alt="enter image description here"></p>
  
  <p>I cant understand why this is happening as the above 404 errors match perfectly to the locations of my CSS files
  <code>/var/www/bias_experiment/static/survey/css/bootstrap.css</code> </p>
  
  <p>I've tried to solve this for a few days but cant crack the problem.</p>
  
  <p>Below is all of my setup. I thought it best to include everything that might be useful and all the steps I have taken. Apologies for the length. </p>
  
  <p><strong>settings.py</strong></p>
  
  <pre><code>DEBUG = True
  
  STATIC_ROOT = '/var/www/bias_experiment/static/'
  STATIC_URL = '/bias_experiment/static/'
  
  STATICFILES_DIRS = ( 
                      '/var/www/bias_experiment/src/survey/static/survey/css', 
                      '/var/www/bias_experiment/src/survey/static/survey/js', 
                      '/var/www/bias_experiment/src/survey/static/survey/fonts', 
  )
  </code></pre>
  
  <p>I am using <code>STATIC_URL = '/bias_experiment/static/'</code> because I am using a VM which has been made publicly available through <a href="http://phaedrus.scss.tcd.ie/bias_experiment/" rel="nofollow noreferrer">http://phaedrus.scss.tcd.ie/bias_experiment/</a></p>
  
  <p>If I use <code>STATIC_URL = '/static/'</code> I get 403 forbidden errors. </p>
  
  <p><strong>slide_test.html</strong></p>
  
  <pre><code>{% load staticfiles %}      
  &lt;!-- THESE WORK LOCALY BUT DO NOT WORK ON THE SERVER --&gt;              
  &lt;link rel = "stylesheet" href ="{% static "survey/css/bootstrap.min.css" %}" &gt;
  &lt;link rel = "stylesheet" href ="{% static "survey/css/bootstrap.css" %}"&gt;               
  &lt;link rel="stylesheet" href ="{% static "survey/css/jquery-ui.css" %}"&gt;                 
  &lt;link rel="stylesheet" href ="{% static "survey/css/slider.css" %}"&gt;                
  
  &lt;script src="{% static "survey/js/jquery.min.js" %}"&gt;&lt;/script&gt;               
  &lt;script src="{% static "survey/js/jquery-ui.js" %}"&gt;&lt;/script&gt;   
  &lt;script src="{% static "survey/js/slider.js" %}"&gt;&lt;/script&gt;
  </code></pre>
  
  <p><strong>My default apache file</strong> /etc/apache2/sites-available/default</p>
  
  <pre><code>Alias /static/ /var/www/bias_experiment/static/
  &lt;Directory /var/www/bias_experiment/static&gt;
  Order deny,allow
  Allow from all
  &lt;/Directory&gt;
  
  
  WSGIScriptAlias /bias_experiment /var/www/bias_experiment/src/bias_experiment/index.wsgi
  &lt;Directory /var/www/bias_experiment/src/bias_experiment&gt;
  &lt;Files index.wsgi&gt;
  Order deny,allow
  Allow from all
  &lt;/Files&gt;
  &lt;/Directory&gt;
  
  ...
  standard apache default settings here
  ...
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>As per the DjangoProject 1.6 Documentation (I am using Apache/2.2.22 (Ubuntu))</p>
  
  <blockquote>
    <p>If you are using a version of Apache older than 2.4, replace Require
    all granted with Allow from all and also add the line Order deny,allow
    above it.</p>
  </blockquote>
  
  <p>I have restarted and reloaded Apache</p>
  
  <p><code>sudo service apache2 restart</code> <code>sudo service apache2 reload</code></p>
  
  <p>I have no problem running collectstatic</p>
  
  <p><img src="https://i.stack.imgur.com/dniCH.png" alt="enter image description here"></p>
  
  <p>I have set ownership of the collected files to www-data:www-data with the below command</p>
  
  <pre><code>sudo chown -R www-data:www-data /var/www/bias_experiment/static/
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/QPApU.png" alt="enter image description here"></p>
  
  <p>I have even disabled and re-enabled the default file in apache2</p>
  
  <pre><code>sudo a2dissite default
  
  sudo a2ensite default
  </code></pre>
  
  <p>and then restarted</p>
  
  <p><code>sudo service apache2 restart</code> <code>sudo service apache2 reload</code></p>
  
  <p>I am using</p>
  
  <ul>
  <li>Ubuntu 12.04 </li>
  <li>Apache 2.22 </li>
  <li>Django 1.6</li>
  <li>mod_wsgi Version: 3.3-4ubuntu0.1</li>
  </ul>
  
  <p>An absolute path to one of the CSS files is <a href="http://phaedrus.scss.tcd.ie/bias_experiment/static/survey/css/bootstrap.min" rel="nofollow noreferrer">http://phaedrus.scss.tcd.ie/bias_experiment/static/survey/css/bootstrap.min</a> in case it is of any use. </p>
  
  <p>However I cant seem to get the <a href="http://phaedrus.scss.tcd.ie/bias_experiment/slide_test/" rel="nofollow noreferrer">test deployment page I am working to show its CSS or JS</a>. 
  I really am not sure what I'm leaving out. If anyone can make any suggestions it would be hugely appreciated. </p>
  
  <p>I asked a similar question to this a few days ago which i have deleted as there were too many mistakes on my part and it lacked both detail and a clear issue. </p>
  
  <p>Thanks</p>