在mod_wsgi上部署django应用程序的问题

时间:2011-03-03 15:40:41

标签: python django apache deployment mod-wsgi

我似乎在使用mod_wsgi部署django时遇到问题。在过去,我使用过mod_python,但我想进行更改。我一直在这里使用Graham Dumpleton笔记http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango 1,但它似乎仍无效。我收到内部服务器错误。

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.

2 个答案:

答案 0 :(得分:1)

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

您有两个选项,您可以创建/.python-eggs并使其成为可写的(或者至少可由Apache运行的用户写入),或者您可以设置PYTHON_EGG_CACHE(使用WSGIPythonEggs directive)到您具有写访问权限的目录。

答案 1 :(得分:1)

# Avoid [Errno 13] Permission denied: '/var/www/.python-eggs' messages
import os

os.environ['PYTHON_EGG_CACHE'] = '/tmp'