1
votes

I've been a django developer for years now, yet a small practice project with 1.7 is giving me a great headache when it comes to serving static files.

I've set STATIC_ROOT

STATIC_ROOT = '/var/www/mydomain/static'

I've set STATIC_URL

STATIC_URL = '/static/' #as default

I'm not using STATICFILES_DIRS since I have one app called 'pages' and it's in INSTALLED_APPS. On localhost the static files are served correctly

I'm using Ubuntu 14.4 and Apache/2.4.7

My apache conf is

<VirtualHost *:80>
    ServerName mydomain.net #I own the domain and pointed it correctly in GoDaddy
    ServerAlias www.mydomain.net

    Alias /static/ /var/www/mydomain/static

    <Directory /var/www/mydomain/static>
        Require all granted
    </Directory>

    WSGIScriptAlias / /var/www/mydomain/mydomain/wsgi.py

    <Directory /var/www/mydomain/mydomain>
        <Files wsgi.py>
           Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess mydomain.net python-path=/var/www/mydomain:/var/www/mydomain/venv/lib/python2.7/site-packages
    WSGIProcessGroup mydomain.net
</VirtualHost>

I've run collectstatic and confirmed all static files are in /var/www/mydomain/static/*.

The site loads, but I get a 404 on all css and js files.

All debugging efforts have failed. I've removed the STATIC_ROOT dir to expect a 403, but still getting a 404. I've chown'd all files/folder to root for testing; nothing. I created a deploy user and chown'd all files/folders to it; nothing. I've chown'd all files/folders to www-data; nothing!!

Is there a new config in Apache 2.4+ that's throwing me off?

1
are you getting a 404 from apache or django? can you post a snippet of your apache /var/log/error.log (or whatever) for when you get a 404. Lastly, are you running on something using SELinux? - Foon
any update on this thread? - Lex Bryan
Maybe show a curl call of your site? Maybe try /static instead of /static/? - sjas

1 Answers

-1
votes

What you can do is check your /var/www/mydomain path and look for the folder. I think its not there yet. If not then copy your folder to this place so that apache can serve it. That will be worth looking