【问题标题】:Problem with deploying django application on mod_wsgi [closed]在 mod_wsgi 上部署 django 应用程序的问题 [关闭]
【发布时间】:2011-03-03 15:40:40
【问题描述】:

我似乎在使用 mod_wsgi 部署 django 时遇到问题。过去我使用过 mod_python,但我想做出改变。我一直在这里使用 Graham Dumpleton 笔记http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango1,但它似乎仍然不起作用。我收到内部服务器错误。

django.wsgi file:

import os
import sys

sys.path.append('/var/www/html')
sys.path.append('/var/www/html/c2duo_crm')

os.environ['DJANGO_SETTINGS_MODULE'] = 'c2duo_crm.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

WSGIScriptAlias / /var/www/html/c2duo_crm/apache/django.wsgi

Apache httpd file:

<Directory /var/www/html/c2duo_crm/apache>
Order allow,deny
Allow from all
</Directory>

在我的 apache 错误日志中,它说我有这个错误这不是全部,但我有最重要的部分:

[Errno 13] Permission denied: '/.python-eggs'
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1]
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1] The Python egg cache directory is currently set to:
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1]
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1]   /.python-eggs
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1]
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1] Perhaps your account does not have write access to this directory?  You can
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1] change the cache directory by setting the PYTHON_EGG_CACHE environment
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1] variable to point to an accessible directory.

【问题讨论】:

    标签: python django apache deployment mod-wsgi


    【解决方案1】:

    Python Eggs 是包含在 zip 文件中的模块文件。 Python Egg Cache 是 Python 提取它们以便运行它们的目录。目前您正在尝试将它们提取到 /.python-eggs 但您没有对该目录的写访问权,如果 / 不存在,您也没有写访问权。

    您有两个选择,您可以创建 /.python-eggs 并使其在世界范围内可写(或至少可由运行 Apache 的用户写入),或者您可以将 PYTHON_EGG_CACHE(使用 WSGIPythonEggs directive)设置为你有写权限的目录。

    【讨论】:

    • 我记得在尝试使用 mod_python 进行部署时遇到了同样的问题。我所做的是我的 httpd 文件中有SetEnv PYTHON_EGG_CACHE /tmp,这会起作用。但是,这不适用于 mod_wsgi。
    • 您是否尝试使用我链接到的 WSGIPythonEggs 指令?如果错误消息未提及 /tmp,则无法识别环境变量。
    • WSGIPythonEggs /tmp 放在 apache htppd 文件中似乎可以正常工作。谢谢
    • WSGIPythonEggs 指令仅适用于嵌入式模式,不适用于守护程序模式。有关在 WSGI 脚本文件中设置它的方式,请参阅位于“code.google.com/p/modwsgi/wiki/…”的文档。顺便说一句,您最好使用守护程序模式。
    【解决方案2】:
    # Avoid [Errno 13] Permission denied: '/var/www/.python-eggs' messages
    import os
    
    os.environ['PYTHON_EGG_CACHE'] = '/tmp'
    

    【讨论】:

      猜你喜欢
      • 2012-12-20
      • 1970-01-01
      • 2018-03-30
      • 2012-07-15
      • 2020-11-02
      • 2015-08-07
      • 2011-10-28
      • 2012-02-01
      • 1970-01-01
      相关资源
      最近更新 更多