在mod\wsgi上部署Django应用程序时出现问题

2024-06-28 18:53:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我在使用mod\wsgi部署django时似乎遇到了一个问题。过去我用过mod峎python,但我想做些改变。我一直在这里使用grahamdumpleton注释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:

^{pr2}$

在我的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.

Tags: todjangoimportclientwsgivarhtmlwww
2条回答

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

您有两个选项,您可以创建/.python eggs并使其成为可写的(或者至少对于运行Apache的用户来说是可写的),或者您可以将python_EGG_缓存(使用WSGIPythonEggs directive)设置到您确实具有写访问权限的目录。在

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

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

相关问题 更多 >