403由于服务器配置拒绝客户端而被禁止

2024-06-28 16:11:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我正处于启动Django webapp的最后阶段,我已经被难住了好几天,试图理解为什么我总是得到一个403禁止的错误(你没有权限访问/在这个服务器上)。当我检查错误日志时,输出的最后一部分如下:

[Fri Sep 11 04:54:04.525052 2015] [:error] [pid 31126:tid 140413402863360] [client 104.156.102.54:62884] ImportError: No module named foodshop.settings
[Fri Sep 11 05:10:08.926570 2015] [mpm_event:notice] [pid 31122:tid 140413615802240] AH00491: caught SIGTERM, shutting down
[Fri Sep 11 05:10:09.912491 2015] [mpm_event:notice] [pid 31345:tid 139760551360384] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Fri Sep 11 05:10:09.912511 2015] [core:notice] [pid 31345:tid 139760551360384] AH00094: Command line: '/usr/sbin/apache2' 
[Fri Sep 11 05:10:15.259159 2015] [authz_core:error] [pid 31349:tid 139760274188032] [client 104.156.102.54:63064] AH01630: client denied by server configuration: /home/ubuntu/foodshop
[Fri Sep 11 05:15:00.604266 2015] [mpm_event:notice] [pid 31345:tid 139760551360384] AH00491: caught SIGTERM, shutting down
[Fri Sep 11 05:15:01.657535 2015] [mpm_event:notice] [pid 31455:tid 140370721130368] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Fri Sep 11 05:15:01.657552 2015] [core:notice] [pid 31455:tid 140370721130368] AH00094: Command line: '/usr/sbin/apache2'
[Fri Sep 11 05:15:06.215273 2015] [authz_core:error] [pid 31458:tid 140370621613824] [client 104.156.102.54:63126] AH01630: client denied by server configuration: /home/ubuntu/foodshop
[Fri Sep 11 05:15:07.389851 2015] [authz_core:error] [pid 31458:tid 140370613221120] [client 104.156.102.54:63126] AH01630: client denied by server configuration: /home/ubuntu/foodshop
[Fri Sep 11 05:15:08.519875 2015] [authz_core:error] [pid 31458:tid 140370427979520] [client 104.156.102.54:63126] AH01630: client denied by server configuration: /home/ubuntu/foodshop
[Fri Sep 11 05:33:55.993127 2015] [mpm_event:notice] [pid 31455:tid 140370721130368] AH00491: caught SIGTERM, shutting down
[Fri Sep 11 05:33:56.047551 2015] [mpm_event:notice] [pid 31598:tid 140492520712064] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Fri Sep 11 05:33:56.047572 2015] [core:notice] [pid 31598:tid 140492520712064] AH00094: Command line: '/usr/sbin/apache2'
[Fri Sep 11 05:34:01.575422 2015] [authz_core:error] [pid 31602:tid 140492306102016] [client 104.156.102.54:63348] AH01630: client denied by server configuration: /home/ubuntu/foodshop
[Fri Sep 11 05:34:02.481030 2015] [authz_core:error] [pid 31602:tid 140492297709312] [client 104.156.102.54:63348] AH01630: client denied by server configuration: /home/ubuntu/foodshop
[Fri Sep 11 05:34:03.342911 2015] [authz_core:error] [pid 31602:tid 140492289316608] [client 104.156.102.54:63348] AH01630: client denied by server configuration: /home/ubuntu/foodshop

需要注意的是…应用程序在我的本地主机上运行得很好。另外,我运行了sudo chown-rwww data apache2.conf将所有权更改为apache。我很乐意分享整个错误日志,如果它会更有用的话,但它很长。在

我在一个EC2实例(ubuntu14.04)上运行这个。在

你可以看到我的000-默认.conf文件如下:

^{pr2}$

Tags: coreclientbyservererrorpidconfigurationsep
1条回答
网友
1楼 · 发布于 2024-06-28 16:11:25

在apache2.conf文件中,确保它看起来像这样:

<Directory /path/to/project/>
        WSGIProcessGroup name
        WSGIApplicationGroup %{GLOBAL}
        Options All
        AllowOverride All
        Require all granted
</Directory>

而不是像这样(这是Apache2.2的配置,而上面是Apache2.4的配置)

^{pr2}$

编辑

尝试将apache配置更改为以下内容(不确定应用程序的根目录是什么,您可能需要将change一行添加到:<Directory /home/ubuntu/gather/src/foodshop/>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

WSGIDaemonProcess gather processes=2 threads=15
WSGIScriptAlias / /home/ubuntu/gather/src/foodshop/wsgi.py

<Directory /home/ubuntu/gather/src/>
    WSGIProcessGroup gather
    WSGIApplicationGroup %{GLOBAL}
    Options All
    AllowOverride All
    Require all granted
</Directory>

Alias /media/ /home/ubuntu/gather/src/foodshop/media/
<Directory /home/ubuntu/gather/src/foodshop/media/>
    Options FollowSymLinks MultiViews
    Order deny,allow
    Allow from all
</Directory>

Alias /static/ /home/ubuntu/gather/src/foodshop/static/
<Directory /home/ubuntu/gather/src/foodshop/static/>
    Options FollowSymLinks MultiViews
    Order allow,deny
    Allow from all
</Directory>

相关问题 更多 >