[Answer]-Why does switching to Apache break all static files in my Django application?

1👍

The best option for work with apache2 and wsgi and django is use a new file in /etc/apache2/sites-enabled/mynewsite.apache (the extension doesn´t matter)

The file must look like this:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin diego@diegue.us
    ServerName yourproject.com.co
    Alias /admin/media/ /path/to/your/admin/media/
    Alias /media/ /path/to/your/media/
    Alias /static/ /path/to/your/static/collected/files/

    <Directory /path/to/your/admin/media/>
        Order deny,allow
        Allow from all
    </Directory>

    <Directory /path/to/your/media/>
        Order deny,allow
        Allow from all
    </Directory>

    <Directory /path/to/your/static/collected/files/>
        Order deny,allow
        Allow from all
    </Directory>

    WSGIScriptReloading On
    WSGIDaemonProcess yourproject python-path=/path/of/packages/for/python # (this is because I use virtualenvwrapper)
    WSGIProcessGroup yourproject
    WSGIApplicationGroup yourproject
    WSGIPassAuthorization On

    WSGIScriptAlias / /path/to/your/yourproject.wsgi
    ErrorLog /var/log/apache2/yourproject-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug

    CustomLog /var/log/apache2/yourproject-access.log combined

</VirtualHost>

You need to tell apache to serve your django application but also you need tell it that Apache serves the files.

Leave a comment