2

I'm trying to setup Django (Django 1.9.6) on Apache (Apache 2.4.10) in my vps (ubuntu server 15.04).

I followed this guide: HERE

Unfortunately when I try to visit my website, the server return this error (403 Forbidden):`

[authz_core:error]  AH01630: client denied by server configuration: /home/user/proj/proj/wsgi.py

I searched everywhere for a solution but everything I tried didn't work.

this is my /etc/apache2/sites-available/000-default.conf file:

    Alias /static /home/user/proj/Gestione/static
    <Directory /home/user/proj/Gestione/static>
        Order deny,allow
        Allow from all
    </Directory>

    <Directory /home/user/proj/proj>
        <Files wsgi.py>
            Order deny,allow
            Allow from all
        </Files>
    </Directory>
    WSGIDaemonProcess proj python-path=/home/user/proj:/home/user/.local/lib/python3.4/site-p$
    WSGIProcessGroup proj
    WSGIScriptAlias / /home/user/proj/proj/wsgi.py

Then i found this code on /etc/apache2/apache2.conf, I don't know if this could create problems:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

This is my wsgy.py:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")
application = get_wsgi_application()

I'm NOT using virtualenv

Thanks for help

big
  • 73
  • 1
  • 9

1 Answers1

1

In Apache 2.4, you should use Require all granted instead of Order deny,allow and Allow from all.

It looks like you are using the old style in two places in 000-default.conf. Try updating it to:

<Directory /home/user/proj/Gestione/static>
    Require all granted
</Directory>

<Directory /home/user/proj/proj>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>
Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • `[wsgi:error] mod_wsgi (pid=9976): Target WSGI script /home/user/proj/proj/wsgi.py cannot be loaded as Python module.` now return this error with "500 internal server error" – big May 15 '16 at 12:38
  • @big can you update the question with what your apache logs say (guesses on potential issues include: permissions on the files (I normally put django stuff someplace apache can get to and make apache own the files) or a wsgi python2 vs python3 issue) – Foon May 15 '16 at 12:59
  • That's a separate issue. Please either update your question to include ` Require all granted` (like your tutorial says you should), and I'll delete this answer, or ask a new question. If there is a traceback in the logs, include the full traceback in the question. – Alasdair May 15 '16 at 15:16
  • @Foon updated question: [click here](http://stackoverflow.com/questions/37255292/django-500-internal-server-error-no-module-named-django) – big May 16 '16 at 13:38