2016-03-30 47 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>