MikkoP
MikkoP

Reputation: 646

Django and Apache / mod_wsgi not rendering css

I'm at a complete loss here as I've taken a ton of steps and nothing helps. The weirdest part is that the css was working earlier today and I don't know where I would've made big changes.

Here are the steps I've taken so far:

Ran

$sudo chown -R www-data lbog/ (lbog is the name of the project)

$sudo chmod -R 777 lbog/ (got a bit frustrated and went with 777)

in /var/www/lbog/ folder

Ran

$python manage.py collectstatic

restarted Apache (quite a few times during the process)

Opened the page in Firebug, copied the link to the css-file and opened the file without problems in another tab. So the path should be correct. Also, as I mentioned, the css was working earlier.

Here are hopefully all the relevant config files.

lbog.conf from /etc/apache2/sites-available. The media stuff is commented out on purpose. (Also ran "$a2ensite lbog.conf" again and the response was "Site lbog.conf already enabled"):

<VirtualHost *:80>

WSGIScriptAlias / /var/www/lbog/apache/django.wsgi

ServerName example.com   #changed for the post
#    ServerAlias www.example.com  #changed for the post
#    ServerAdmin [email protected]

DocumentRoot /var/www/lbog

Alias /static /var/www/lbog/static/

#  Alias /media /var/www/lbog/media/
#  <Directory /var/www/lbog/media>
#      Order allow,deny
#      Allow from all
#  </Directory>

<Directory /var/www/lbog>
    Order allow,deny
    Allow from all
</Directory>


<Directory /var/www/lbog/apache>
    Order allow,deny
    Allow from all
</Directory>

</VirtualHost>

django.wsgi (located in the right directory)

import os
import sys
sys.path.append('/var/www/lbog/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'lbog.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

and settings.py (hopefully all relevant bits)

STATIC_ROOT = '/var/www/lbog/static/'

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = 'example.com/static/'  #changed for this post

# Additional locations of static files
STATICFILES_DIRS = (
    ('global', '/var/www/lbog/globalstatic/',),
    ('users', '/var/www/lbog/users/templates/static/'),
)

This is driving me mad, so if anyone is able to help I'd be most thankful.

Oh and here's a snippet from Apache's error log which shows something (it was showing files not being accessed correctly when I was configuring the paths and the templates):

[Wed Jul 10 22:22:35 2013] [notice] caught SIGTERM, shutting down 

[Wed Jul 10 22:23:20 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.6-1ubuntu1.2 mod_wsgi/3.4 Python/2.7.3 configured -- resuming normal operations 

[Wed Jul 10 22:25:10 2013] [notice] caught SIGTERM, shutting down 

[Wed Jul 10 22:25:11 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.6-1ubuntu1.2 mod_wsgi/3.4 Python/2.7.3 configured -- resuming normal operations –

Upvotes: 0

Views: 1219

Answers (1)

MikkoP
MikkoP

Reputation: 646

Yeah never mind... At some point I had changed the STATIC_URL variable to "example.com/static/" whereas it only needs to be "/static/". Everything works again. Hopefully there's at least a list of things to try if yours isn't working...

Upvotes: 1

Related Questions