2011-03-03 77 views
1

我似乎遇到了用mod_wsgi部署django的問題。在過去,我使用mod_python,但我想進行更改。我一直在使用Graham Dumpleton筆記http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango1,但它似乎仍然不起作用。我得到一個內部服務器錯誤。在mod_wsgi上部署django應用程序的問題

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. 

回答

1

Python Egg s是模塊文件是con在zip文件中保存。 Python Egg Cache是​​Python提取它們的目錄,所以它可以運行它們。目前,您正試圖將它們解壓縮到/.python-eggs,但是您沒有對該目錄的寫入權限,或者如果它不存在,則不能寫入。您可以創建/.python-eggs並將其設置爲全局可寫(或者至少可以由Apache運行的用戶寫入),也可以將PYTHON_EGG_CACHE(使用WSGIPythonEggs directive)設置爲一個目錄你有寫入權限。

+0

我記得當我嘗試使用mod_python進行部署時遇到同樣的問題。我所做的是我在我的httpd文件中設置了'SetEnv PYTHON_EGG_CACHE/tmp',這會起作用。但是這不適用於mod_wsgi。 – Shehzad009 2011-03-03 16:18:14

+0

您是否嘗試使用我鏈接到的WSGIPythonEggs指令?如果錯誤消息沒有提及/ tmp,那麼環境變量沒有被識別。 – 2011-03-03 16:22:05

+0

將'WSGIPythonEggs/tmp'放在apache htppd文件中似乎已經可以使其工作。謝謝 – Shehzad009 2011-03-03 16:45:02

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

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