Django on apache with mod_wsgi (Linux) - 403 Forbidden

Ok, so I follow this tutorial. When I try to access my site through my local server, I get this strange error:

Forbidden You don't have permission to access / on this server. Apache/2.4.6 (Ubuntu) Server at mysite.com Port 80.

Αs, as far as I'm interested, I did everything right (I implemented the twice proposed method), and this can easily be an OS error (I am running Mint 16, but the error says (Ubuntu)), however I do not experience it and therefore I need help.

I did some research, but none of them ( 1 , 2 ), along with others, seem to be responding to my case.

So here is the mysite.conffile:

<VirtualHost *:80>
WSGIScriptAlias / /home/nick/Mysite/mysite.wsgi

ServerName mysite.com
Alias /static /var/www/mysite/static/

<Directory /var/www/mysite/>

Options All
AllowOverride All
Require all granted

</Directory>
</VirtualHost>

and my hostsfile, which shows how the IP address is redirected to my local host:

127.0.0.1   localhost
127.0.1.1   nick-HP-Notebook-PC
192.168.1.2 mysite.com
192.168.1.2 mysite2.com

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

, , . Linux ? , , , - .

.

Update:

.wsgi:

import os
import sys
sys.path = ['/var/www/mysite'] + sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

, .

Restarting web server apache2                                                AH00558: apache2: Could not reliably determine the server fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message         [ OK ]

, ?

+4
3

, , , , . .

WSGIScriptAlias, .

WSGI :

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
+1

:

WSGIScriptAlias / /home/nick/Mysite/mysite.wsgi

:

<Directory/home/nick/Mysite>
<Files mysite.wsgi>
Require all granted
</Files>
</Directory>

, , /home/nick, , Apache .

:

Alias /static /var/www/mysite/static/

. , URL- , , URL- . , .

+1

.

.wsgi script /var/www/mysite/, .

Also remove the lead / in:

.. Alias /static /var/www/mysite/static ..

+1
source

Source: https://habr.com/ru/post/1523908/


All Articles