[ACCEPTED]-Django Static File Hosting an Apache-alias

Accepted answer
Score: 52

Figured it out. I had an apache config error 3 on this line:

Alias /static/ /home/daifotis/code/feris/sitestatic

I should have written static 2 without the trailing slash. With the trailing 1 slash Apache will not expand the URL path.

Alias /static /home/daifotis/code/feris/sitestatic
Score: 2

I'm assuming you're using Django 1.3, and 17 the 'new' way of serving static files. Could 16 you please show us the settings in your 15 settings.py file relating to MEDIA and STATIC? Both 14 the ROOT AND URL versions. Also show your 13 STATICFILES_DIRS.

The most likely cause is 12 that Django is only configured to serve 11 static files with contrib.staticfiles. It's possible that you'll 10 need to run the management command python manage.py collectstatic to collect 9 all your application static files into a 8 directory ready to be served by apache.

See 7 my answer here regarding settings for using django.contrib.staticfiles.

If your static 6 files exist, 100%, at the directory pointed 5 to by Alias /static/ /home/daifotis/code/feris/sitestatic, then your permissions for apache 4 are probably configured incorrectly. Have 3 you checked the /var/log/httpd/error_log file to see if there is 2 an IOPermissions error when trying to serve 1 the static content?

Score: 0

I know it's an old question, but I had the 4 same problem and I've tried everything. It 3 turned out that I enabled my app.conf in 2 my apache but forgot to disable 000-default.conf 1 in my apache server.

More Related questions