1

I am trying to deploy a Django based product on an Ubuntu server with Apache. Everything goes well so far, and I can get de applications served by Apache, but I find that these applications lose all their styling.

This is the first time I do this, so I made some research and found and followed this tutorial that is pretty good, but I haven't found any reference to the problem I am having.

This is in my settings.py:

STATICFILES_DIRS    = (os.path.join(BASE_DIR,'FrontEndApp','public'),)
STATIC_URL          = '/res/'
STATIC_ROOT         = os.path.join(BASE_DIR, 'static/')

And this is my 000-default.conf:

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


Alias /static /home/axel/IntellibookProject/Intellibook/static
<Directory /home/axel/IntellibookProject/Intellibook/static>
        Require all granted
</Directory>

<Directory /home/axel/IntellibookProject/Intellibook/Intellibook>
        <Files wsgi.py>
                Require all granted
        </Files>
</Directory>

WSGIDaemonProcess Intellibook python-home=/home/axel/IntellibookProject/IntellibookVenv python-path=/home/axel/IntellibookProject/Intellibook
WSGIProcessGroup Intellibook
WSGIScriptAlias / /home/axel/IntellibookProject/Intellibook/Intellibook/wsgi.py

I made the test serving the applications with pyhton manage.py runserver 0.0.0.0:8000, and everything worked perfectly. The problem exists only when the applications are served with Apache.

HuLu ViCa
  • 5,077
  • 10
  • 43
  • 93

1 Answers1

0

You may be losing your static references. When you access the app in a browser, right-click and choose inspect or view page source. Inside inspect, you should be able to see "Sources" and your CSS should show up on that list. This will tell you whether you are referencing the correct filepath or not.

If you are not referencing the correct filepath, change Alias /static /home/axel/IntellibookProject/Intellibook/static in 000-default.conf to reflect the correct static references.

R. Steele
  • 56
  • 8