关于在 Apache 上部署 Django 项目模组Python

发布于 2024-09-06 11:09:40 字数 2878 浏览 6 评论 0原文

我在部署 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡淡離愁欲言轉身 2024-09-13 11:09:40

您需要授予对 /data/www/reviewboard/htdocs 的访问权限

<Directory "/data/www/reviewboard/htdocs">
    Order allow,deny
    Allow from *
    AllowOverride All
</Directory>

You need to grant access to /data/www/reviewboard/htdocs

<Directory "/data/www/reviewboard/htdocs">
    Order allow,deny
    Allow from *
    AllowOverride All
</Directory>
ヅ她的身影、若隐若现 2024-09-13 11:09:40

从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 the media directory, because that directory contains symbolic links.

More detail is in this post:

http://groups.google.com/group/reviewboard/browse_thread/thread/6fac4d0041237f15/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文