0

I have a Django 1.4.5 project called mp which I'm trying to run on my localhost using Apache 2.4. Following the official tutorial for Django with mod_wsgi (How to use Django with Apache and mod_wsgi) I managed to display my Django page when I visit http://127.0.0.1:8801/.

My project folder mp is located in /opt/masterportal/mp, and the static files are located in /opt/masterportal/mp/mp/static.

This is my masterportal.conf file in /etc/apache2/sites-available:

Listen 8081
<VirtualHost *:8081>
     ServerAdmin [email protected]

     XSendFilePath /opt/masterportal/mp/mp/uploads/
     <Files *.*>
         XSendFile On
     </Files>

     WSGIDaemonProcess masterportal python-path=/opt/masterportal/mp:/opt/masterportal/mp/env/dev/lib/python2.7/site-packages
     WSGIProcessGroup masterportal
     WSGIScriptAlias / /opt/masterportal/mp/mp/apache/wsgi.py

     Alias /static /opt/masterportal/mp/mp/static

     <Directory /opt/masterportal/mp/mp/static>
        Require all granted
     </Directory>

     <Location />
        WSGIProcessGroup masterportal
        Require all granted
     </Location>
</VirtualHost>

However, the website at http://127.0.0.1:8801 can't find any of the static files. This is odd, because the exact same project works on the server of my university (where I don't have access to the apache configuration). So there must be something wrong with my Apache configuration, but I can't see what. I'm desperate for help.

Some general information: I'm using Django 1.4.5 (because this is the version on the university server), and Apache 2.4. The project runs in a virtualenv located here /opt/masterportal/mp/env. I also tried it with Alias /static/ instead of Alias /static, but that didn't work either. My apache2.conf is still original - I made no changes there.

Edit: Here's my configuration for the site in /etc/apache2/conf-available/:

    <Location "/mp/2015/suse">
        ProxyPass https://my-computername:8081/
        ProxyPassReverse https://my-computername:8081/
        RequestHeader set X-FORWARDED-PROTOCOL ssl
        RequestHeader set X-FORWARDED-SSL on
    </Location>
2
  • What happens when you go to the path of a static file in your browser? Is this a simple 404, or you can get more logs? Commented Sep 7, 2014 at 16:35
  • @RaphaelLaurent It's a simple 404, no more logs. Commented Sep 7, 2014 at 16:39

1 Answer 1

1

Try to move the lines

Alias /static /opt/masterportal/mp/mp/static

<Directory /opt/masterportal/mp/mp/static>
   Require all granted
</Directory>

before

 WSGIDaemonProcess masterportal python-path=/opt/masterportal/mp:/opt/masterportal/mp/env/dev/lib/python2.7/site-packages
 WSGIProcessGroup masterportal
 WSGIScriptAlias / /opt/masterportal/mp/mp/apache/wsgi.py

because the link with /static/some_static_files... might be forwared to the wsgi app instead of pointing to the static directory.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, but unfortunately it doesn't work either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.