apache + wsgi + django:客户端被服务器配置拒绝
apache + wsgi + django : Client denied by server configuration
我的 Django 项目出现 403 错误。
我在错误日志中得到的唯一一行是:
AH01630: client denied by server configuration: /srv/http/www/src/myproject/preprod_wsgi.py
此文件的权限是:
-rwxr-xr-x 1 root root 552 Jul 30 04:24 preprod_wsgi.py
而 apache(版本:2.4)conf 文件包含(除其他外):
LoadModule wsgi_module modules/mod_wsgi.so
<IfModule unixd_module>
User http
Group http
</IfModule>
<Directory />
AllowOverride none
Require all denied
</Directory>
#
# Others
#
Alias /robots.txt /srv/http/www/htdocs/static/robots.txt
Alias /favicon.ico /srv/http/www/htdocs/static/favicon.ico
Alias /media/ /srv/http/www/htdocs/media/
Alias /static/ /srv/http/www/htdocs/static/
<Directory "/srv/http/www/htdocs/static">
Require all granted
</Directory>
<Directory "/srv/http/www/htdocs/media">
Require all granted
</Directory>
<Files "/srv/http/www/src/myproject/preprod_wsgi.py">
Require all granted
</Files>
#
# WSGI
#
WSGIDaemonProcess myproject python-path=/srv/http/www/src
WSGIScriptAlias / /srv/http/www/src/myproject/preprod_wsgi.py
WSGIPythonPath /srv/http/www/src
DocumentRoot "/srv/http/www/htdocs"
<Directory "/srv/http/www/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ErrorLog "/srv/http/www/logs/error_log"
CustomLog "/srv/http/www/logs/access_log" common
LogLevel warn
这也是我的preprod_wsgi.py文件的内容:
"""
WSGI config for soisbault project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os, sys
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.preprod_settings")
application = get_wsgi_application()
ALLOWED_HOSTS
也设置在我的preprod_settings.py
.
我尝试使用 <Files>
指令添加对此文件的访问权限,并对其执行了 chmod 755
。但是我不知道我还能做些什么。
我该如何解决这个问题?如有必要,请随时询问更多详情。
提前谢谢你。
似乎是 apache 中的 指令不能在 指令之外使用。
<Files "/srv/http/www/src/myproject/preprod_wsgi.py">
Require all granted
</Files>
我改成了
<Directory "/srv/http/www/src/myproject">
<Files "preprod_wsgi.py">
Require all granted
</Files>
</Directory>
它奏效了。 :)
我的 Django 项目出现 403 错误。
我在错误日志中得到的唯一一行是:
AH01630: client denied by server configuration: /srv/http/www/src/myproject/preprod_wsgi.py
此文件的权限是:
-rwxr-xr-x 1 root root 552 Jul 30 04:24 preprod_wsgi.py
而 apache(版本:2.4)conf 文件包含(除其他外):
LoadModule wsgi_module modules/mod_wsgi.so
<IfModule unixd_module>
User http
Group http
</IfModule>
<Directory />
AllowOverride none
Require all denied
</Directory>
#
# Others
#
Alias /robots.txt /srv/http/www/htdocs/static/robots.txt
Alias /favicon.ico /srv/http/www/htdocs/static/favicon.ico
Alias /media/ /srv/http/www/htdocs/media/
Alias /static/ /srv/http/www/htdocs/static/
<Directory "/srv/http/www/htdocs/static">
Require all granted
</Directory>
<Directory "/srv/http/www/htdocs/media">
Require all granted
</Directory>
<Files "/srv/http/www/src/myproject/preprod_wsgi.py">
Require all granted
</Files>
#
# WSGI
#
WSGIDaemonProcess myproject python-path=/srv/http/www/src
WSGIScriptAlias / /srv/http/www/src/myproject/preprod_wsgi.py
WSGIPythonPath /srv/http/www/src
DocumentRoot "/srv/http/www/htdocs"
<Directory "/srv/http/www/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ErrorLog "/srv/http/www/logs/error_log"
CustomLog "/srv/http/www/logs/access_log" common
LogLevel warn
这也是我的preprod_wsgi.py文件的内容:
"""
WSGI config for soisbault project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os, sys
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.preprod_settings")
application = get_wsgi_application()
ALLOWED_HOSTS
也设置在我的preprod_settings.py
.
我尝试使用 <Files>
指令添加对此文件的访问权限,并对其执行了 chmod 755
。但是我不知道我还能做些什么。
我该如何解决这个问题?如有必要,请随时询问更多详情。
提前谢谢你。
似乎是 apache 中的
<Files "/srv/http/www/src/myproject/preprod_wsgi.py">
Require all granted
</Files>
我改成了
<Directory "/srv/http/www/src/myproject">
<Files "preprod_wsgi.py">
Require all granted
</Files>
</Directory>
它奏效了。 :)