关于在 Apache 上部署 Django 项目模组Python
我在部署 Django 项目 - Review Board 时遇到问题。我按照文档中的说明进行操作,但在尝试访问该网站时出现“错误 403”错误。也许我应该在 serverfault.com 上发布这个问题,但我认为这可能有助于人们编写/部署 Django 应用程序。
安装如下:
我将Review Board安装在/data/www/reviewboard
中:
. |-- conf | |-- apache-modpython.conf | |-- search-cron.conf | `-- settings_local.py |-- db | `-- reviewboard.db |-- htdocs | |-- errordocs -> /usr/lib/python2.6/site-packages/ReviewBoard-1.0.8-py2.6.egg/reviewboard/htdocs/errordocs | |-- media | | |-- admin -> /usr/lib/python2.6/site-packages/ReviewBoard-1.0.8-py2.6.egg/reviewboard/htdocs/media/admin | | |-- djblets -> /usr/lib/python2.6/site-packages/Djblets-0.6.2-py2.6.egg/djblets/media | | |-- rb -> /usr/lib/python2.6/site-packages/ReviewBoard-1.0.8-py2.6.egg/reviewboard/htdocs/media/rb | | `-- uploaded | | `-- images | `-- rb | |-- errordocs -> ../errordocs/ | `-- media -> ../media/ |-- logs `-- tmp
所有文件对httpd用户都有读取权限,数据库和uploaded
目录有写入权限对于 httpd 用户。
conf/apache-modpython.conf
的内容是:
<VirtualHost *:80>
ServerName A.B.C.edu
DocumentRoot "/data/www/reviewboard/htdocs"
# Error handlers
ErrorDocument 500 /errordocs/500.html
# Serve django pages
<Location "/rb">
PythonPath "['/data/www/reviewboard/conf'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE reviewboard.settings
SetEnv PYTHON_EGG_CACHE "/data/www/reviewboard/tmp/egg_cache"
SetHandler mod_python
PythonHandler django.core.handlers.modpython
PythonAutoReload Off
PythonDebug Off
# Used to run multiple mod_python sites in the same apache
PythonInterpreter reviewboard_reviewboard
</Location>
# Serve static media without running it through mod_python
# (overrides the above)
<Location "/media">
SetHandler None
</Location>
<Location "/errordocs">
SetHandler None
</Location>
<Directory "/data/www/reviewboard/htdocs">
AllowOverride All
</Directory>
# Alias static media requests to filesystem
Alias /media /data/www/reviewboard/htdocs/media
Alias /errordocs /data/www/reviewboard/htdocs/errordocs
</VirtualHost>
我也在 Apache 主配置文件 /etc 中引用了这个文件/httpd/conf/httpd.conf
像这样:
包括/data/www/reviewboard/conf/apache-modpython.conf
当我尝试通过 http://ABCedu/rb
访问该网站时,出现 403 错误,并在 httpd 错误日志中看到此消息:
[Tue Jun 22 08:52:57 2010] [notice] Apache/2.2.11 (Mandriva Linux/PREFORK-10.1mdv2009.1) mod_python/3.3.1 Python/2.6.1 DAV/2 SVN/1.6.1 mod_ssl/2.2.11 OpenSSL/0.9.8k configured -- resuming normal operations [Tue Jun 22 08:53:30 2010] [error] [client X.X.X.X] client denied by server configuration: /data/www/reviewboard/htdocs/rb
有人知道我做错了什么吗?提前致谢!
I had problems deploying a Django project - Review Board. I did what the document says and but got "Error 403" errors when I tried visiting the site. Maybe I should have posted this question on serverfault.com, but I think this may help people write/deploy Django application in general.
Here is the installation:
I installed Review Board in /data/www/reviewboard
:
. |-- conf | |-- apache-modpython.conf | |-- search-cron.conf | `-- settings_local.py |-- db | `-- reviewboard.db |-- htdocs | |-- errordocs -> /usr/lib/python2.6/site-packages/ReviewBoard-1.0.8-py2.6.egg/reviewboard/htdocs/errordocs | |-- media | | |-- admin -> /usr/lib/python2.6/site-packages/ReviewBoard-1.0.8-py2.6.egg/reviewboard/htdocs/media/admin | | |-- djblets -> /usr/lib/python2.6/site-packages/Djblets-0.6.2-py2.6.egg/djblets/media | | |-- rb -> /usr/lib/python2.6/site-packages/ReviewBoard-1.0.8-py2.6.egg/reviewboard/htdocs/media/rb | | `-- uploaded | | `-- images | `-- rb | |-- errordocs -> ../errordocs/ | `-- media -> ../media/ |-- logs `-- tmp
All files have read permission for the httpd user and the database and the uploaded
directory have write permission for the httpd user.
The content of conf/apache-modpython.conf
is:
<VirtualHost *:80>
ServerName A.B.C.edu
DocumentRoot "/data/www/reviewboard/htdocs"
# Error handlers
ErrorDocument 500 /errordocs/500.html
# Serve django pages
<Location "/rb">
PythonPath "['/data/www/reviewboard/conf'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE reviewboard.settings
SetEnv PYTHON_EGG_CACHE "/data/www/reviewboard/tmp/egg_cache"
SetHandler mod_python
PythonHandler django.core.handlers.modpython
PythonAutoReload Off
PythonDebug Off
# Used to run multiple mod_python sites in the same apache
PythonInterpreter reviewboard_reviewboard
</Location>
# Serve static media without running it through mod_python
# (overrides the above)
<Location "/media">
SetHandler None
</Location>
<Location "/errordocs">
SetHandler None
</Location>
<Directory "/data/www/reviewboard/htdocs">
AllowOverride All
</Directory>
# Alias static media requests to filesystem
Alias /media /data/www/reviewboard/htdocs/media
Alias /errordocs /data/www/reviewboard/htdocs/errordocs
</VirtualHost>
I also cited this file in the main Apache configuration file, /etc/httpd/conf/httpd.conf
like this:
Include /data/www/reviewboard/conf/apache-modpython.conf
When I tried to access the site by http://A.B.C.edu/rb
, I got 403 error and saw this message in httpd error log:
[Tue Jun 22 08:52:57 2010] [notice] Apache/2.2.11 (Mandriva Linux/PREFORK-10.1mdv2009.1) mod_python/3.3.1 Python/2.6.1 DAV/2 SVN/1.6.1 mod_ssl/2.2.11 OpenSSL/0.9.8k configured -- resuming normal operations [Tue Jun 22 08:53:30 2010] [error] [client X.X.X.X] client denied by server configuration: /data/www/reviewboard/htdocs/rb
Does anybody know what I did wrong? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要授予对 /data/www/reviewboard/htdocs 的访问权限
You need to grant access to /data/www/reviewboard/htdocs
从Review Board的作者那里找到了答案。技巧是添加
选项 FollowSymlinks
位于
标记中,指向media
目录,因为该目录包含符号链接。这篇文章中有更多详细信息:
http://groups.google.com/组/reviewboard/browse_thread/thread/6fac4d0041237f15/
Found the answer from the author of Review Board. The trick is to add
Options FollowSymlinks
in the
<Location>
tag that points to themedia
directory, because that directory contains symbolic links.More detail is in this post:
http://groups.google.com/group/reviewboard/browse_thread/thread/6fac4d0041237f15/