Django + mod_wsgi + Apache = 403 Forbidden

时间:2014-07-29 12:30:49

标签: django apache debian mod-wsgi

我一直在Debian上收到此错误。无论我把代码放在哪里。

我已经在这里完成了所有其他问题,并且在我的案例中找不到任何有用的内容。

这是默认的网站配置:

WSGIScriptAlias / /home/user/Code/mysite/core/
WSGIPythonPath /home/user/Code/mysite/core/

<VirtualHost *:80>
        ServerAdmin user@site.com
        ServerName http://example.org
        Options -Indexes
        DocumentRoot /var/www/


        <Directory />
#               Options FollowSymLinks
                AllowOverride None
                Allow from all
        </Directory>


<Directory /home/user/Code/site/core/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

<Directory /var/www>
                Options FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
</Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.:
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

是的,我知道将网站放在home文件夹中并不是一个好习惯,但以后更新真的很棒。我也尝试过所有许可。现在我的家庭目录可以被一个完整的局外人访问和肢解,但仍无济于事。我在这里失去了耐心,因为我已经失去了整整一天试图部署这件事。

Apache日志中的最后几行:

[ 2014-07-29 12:22:13.5464 7242/b7486700 agents/HelperAgent/Main.cpp:619 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.7219/generation-0/request
[ 2014-07-29 12:22:13.5540 7247/b6df2700 agents/LoggingAgent/Main.cpp:318 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.7219/generation-0/logging
[ 2014-07-29 12:22:13.5542 7239/b749e700 agents/Watchdog/Main.cpp:761 ]: All Phusion Passenger agents started!
[Tue Jul 29 12:22:13 2014] [notice] Apache/2.2.22 (Debian) PHP/5.4.4-14+deb7u12 mod_python/3.3.1 Python/2.7.3 mod_wsgi/3.3 Phusion_Passenger/4.0.23 configured -- resuming normal operations
[Tue Jul 29 12:22:18 2014] [error] [client 91.199.251.60] (13)Permission denied: access to / denied
[Tue Jul 29 12:22:20 2014] [error] [client 91.199.251.60] (13)Permission denied: access to / denied
[Tue Jul 29 12:22:21 2014] [error] [client 91.199.251.60] (13)Permission denied: access to / denied
[Tue Jul 29 12:22:21 2014] [error] [client 91.199.251.60] (13)Permission denied: access to / denied
[Tue Jul 29 12:22:22 2014] [error] [client 91.199.251.60] (13)Permission denied: access to / denied
[Tue Jul 29 12:22:22 2014] [error] [client 91.199.251.60] (13)Permission denied: access to / denied
[Tue Jul 29 12:22:24 2014] [error] [client 91.199.251.60] (13)Permission denied: access to / denied
[Tue Jul 29 12:23:06 2014] [error] [client 94.242.206.244] (13)Permission denied: access to /xmlrpc.php denied
~                   

如果需要,我可以提供更大的图片。

1 个答案:

答案 0 :(得分:4)

您使用什么网址访问该网站?

此配置中存在很多问题。如果这是一个Django站点,你甚至在mod_wsgi设置上关注Django文档吗?

有些错误的地方是:

  • ServerName应该是主机名,而不是URL,因此将忽略VirtualHost。
  • WSGIScriptAlias位于VirtualHost之外,由于VirtualHost被忽略,因此忽略了目标目录中Apache安装的访问权限,您将获得禁止响应。
  • 无论如何,WSGIScriptAlias都指的是一个目录,很可能它应该引用wsgi.py文件。
  • 设置来自目录的所有允许/是一个等待发生的安全灾难。