2016-03-30 4 views
0

Ich versuche, meine Anwendung auf dem Webserver (django mit apache2 und mod_wsgi) zu implementieren. Aber ich habe 403 verboten Fehler beim Ausführen der Website .. (Forbidden Sie haben keine Berechtigung auf/auf diesem Server. Apache/2.4.7 (Ubuntu) Server bei 104.131.127.196 Port 80). Die Struktur meiner Web-Anwendung sieht aus, als:403 Verbotener Fehler im django Webserver

CASINOVA 
|-- Casinova 
| |-- db.sqlite3 
| |-- index.html 
| |-- manage.py 
| |-- casinova 
| | |-- __init__.py 
| | |-- __init__.pyc 
| | |-- settings.py 
| | |-- settings.pyc 
| | |-- urls.py 
| | |-- urls.pyc 
| | |-- wsgi.py 
| | `-- wsgi.pyc 
| `-- static 

sudo nano /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80> 
Alias /static /var/www/html/CASINOVA/Casinova/static/ 
<Directory /var/www/html/CASINOVA/Casinova/static> 
Options Indexes FollowSymLinks Includes ExecCGI 
Require all granted 
</Directory> 
<Directory /var/www/html/CASINOVA/Casinova> 
<Files wsgi.py> 
    Require all granted 
</Files> 
</Directory> 
WSGIDaemonProcess Casinova python-path=/var/www/html/CASINOVA/Casinova:/var/www/html/CASINOVA/venv/Casinova/lib/python2.7/si$ 
WSGIProcessGroup Casinova 
WSGIScriptAlias//var/www/html/CASINOVA/Casinova/casinova/wsgi.py 

ServerName 0.0.0.0 
ServerAdmin [email protected] 
DocumentRoot /var/www/html/CASINOVA/Casinova 
ErrorLog ${APACHE_LOG_DIR}/error.log 
CustomLog ${APACHE_LOG_DIR}/access.log combined 
AddHandler cgi-script .py 

sudo vi/etc/apache2/apache2.conf

<Directory /> 
    Options FollowSymLinks 
    AllowOverride None 
    Require all granted 
</Directory> 
<Directory /usr/share> 
    AllowOverride None 
    Require all granted 
</Directory> 
<FilesMatch "^\.ht"> 
    Require all denied 
</FilesMatch> 
IncludeOptional conf-enabled/*.conf 
IncludeOptional sites-enabled/*.conf 
ServerName mydomain.com 

vi /etc/hosts.py

127.0.0.1 localhost 
104.131.127.196 Casinova 
::1 ip6-localhost ip6-loopback 
fe00::0 ip6-localnet 
ff00::0 ip6-mcastprefix 
ff02::1 ip6-allnodes 
ff02::2 ip6-allrouters 
ff02::3 ip6-allhosts 

#ls -l/var/www/html

drwxr-xr-x 4 root root 4096 Mar 29 08:42 CASINOVA 
-rw-r--r-- 1 root root 11510 Mar 30 03:05 index.html 
-rw-r--r-- 1 root root 20 Oct 28 01:42 info.php 

ich den Inhalt aus den Dateien geschrieben haben default.conf, apache2.conf und hosts.py. Was ist der Fehler darin ??

+0

Werfen Sie einen Blick auf 'tail -n 50/var/log/apache2/error.log', es gibt Ihnen einen Hinweis darauf, welche Berechtigungen fehlen. – Cyrbil

+0

Der Fehler war "Optionen ExecCGI ist in diesem Verzeichnis deaktiviert". Ich habe es gelöscht, indem ich "Optionen Indizes FollowSymLinks Includes ExecCGI" mit Optionen Indizes FollowSymLinks MultiViews ersetzt .. Aber der gleiche verbotene Fehler tritt @ Cyrbil – shalin

+0

@shalin Wahrscheinlich eine dumme Frage. Wie kann man die Django-Projektstruktur wie im ersten Codebeispiel in Ihrer Frage erstellen? – r0xette

Antwort

0
<Directory /var/www/html/CASINOVA/Casinova/static> 
Options Indexes FollowSymLinks Includes ExecCGI 
Require all granted 
</Directory> 

Meine Vermutung, setzen ExecCGI für Ihre Django-Verzeichnis, nicht für /static.

<Directory /var/www/html/CASINOVA/Casinova> 
Options ExecCGI 
</Directory>