django static files through apache in windows

162 views
Skip to first unread message

Robin Lery

unread,
Aug 22, 2013, 12:14:42 PM8/22/13
to django...@googlegroups.com
I have configured apache to serve my project. But I can't yet configure it to serve static files. Till now in my httpd.conf I have appended the code that django documentation provides and its like this:

    WSGIScriptAlias / C:/Users/robin/web/facebook/facebook/wsgi.py
    WSGIPythonPath C:/Users/robin/web/facebook/

    <Directory C:/Users/robin/web/facebook/facebook>
    <Files wsgi.py>
    Order deny,allow
    Allow from all
    </Files>
    </Directory>

Now, what next do I do to serve static files through apache server. I know its best to serve static files through nginx or other server, but it was to hard to find tutorial for windows. So I would highly appreciate if someone would guide me to serve static files throught apache as I am half way down there, in windows. Or if some tutorials for other server for windows will also be appreciated. Thank you!

Tom Evans

unread,
Aug 22, 2013, 12:45:30 PM8/22/13
to django...@googlegroups.com
This is documented in django's documentation:

https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/#serving-files

Create a directory somewhere on disk, and add it as a location alias
to your apache config, like so

Alias /static/ C:/path/to/dir/you/made/
<Directory C:/path/to/dir/you/made>
Order deny,allow
Allow from all
</Directory>

Set the following settings:

STATIC_ROOT = "C:/path/to/dir/you/made"
STATIC_URL = "/static/"

Run "python manage.py collectstatic".

Cheers

Tom

Robin Lery

unread,
Aug 22, 2013, 2:06:50 PM8/22/13
to django...@googlegroups.com
my

STATIC_ROOT = 'C:/Users/robin/web/static_files_for_facebook/'

STATIC_URL = '/static/'

In httpd.conf I have added:

#Serve static files
AliasMatch /static/ C:/Users/robin/web/static_files_for_facebook/
<Directory C:/Users/robin/web/static_files_for_facebook>
   Order deny,allow
   Allow from all
</Directory>


After collectstatic command it has collected the static files, but its still now showing up.





Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Robin Lery

unread,
Aug 22, 2013, 2:07:48 PM8/22/13
to django...@googlegroups.com
STATICFILES_DIRS = (
    ('assets','C:/Users/robin/web/facebook/static'),
)

Robin Lery

unread,
Aug 22, 2013, 2:15:56 PM8/22/13
to django...@googlegroups.com
In my html file I have link the css with 'assets', `href="{% static "assets/css/face.css" %}">`. But there are two folders `assets` and `admin`, after I made the command collectstatic. Is it the problem? Should I direct css to `admin`?
Reply all
Reply to author
Forward
0 new messages