2016-03-30 49 views
0

我想在web服務器上部署我的應用程序(django與apache2和mod_wsgi)。 (Forbidden 您沒有權限訪問/在此服務器上。 Apache/2.4.7(Ubuntu)服務器在104.131.127.196端口80)。我的web應用程序的結構看起來是:403 django web服務器中的禁止錯誤

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 

須藤納米/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 

六/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 

我已經發布了從文件的內容default.conf,apache2.conf和hosts.py。那是什麼錯誤?

+0

查看'tail -n 50/var/log/apache2/error.log',它會給你提示什麼權限丟失。 – Cyrbil

+0

錯誤是「Options ExecCGI在此目錄中關閉」。我已經清除它通過替換「選項索引FollowSymLinks包括ExecCGI」與選項索引FollowSymLinks MultiViews ..但同樣的禁止的錯誤發生@Cyrbil – shalin

+0

@shalin可能是一個愚蠢的問題。怎樣才能像你的問題中的第一個代碼示例一樣創建django項目結構? – r0xette

回答

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

我的猜測是,爲您的Django目錄設置ExecCGI,而不是爲/static

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