2012-02-01 107 views
1

我在Mac OSX Lion(10.7.2)上用Apache設置Django時遇到了麻煩。我按照教程創建了一個Django項目,並可以在開發服務器上運行它。現在我想用Apache在我的Mac上本地運行它。我創建瞭如下所示的兩個文件。如何在Mac OSX Lion上設置Django,mod_wsgi和apache?

apache_django_wsgi.conf

WSGIDaemonProcess django 
WSGIProcessGroup django 

Alias /site_media/ "/Users/David/Dropbox/sites/walble/media/" 
<Directory "/Users/David/Dropbox/sites/walble/media"> 
Order allow,deny 
Options Indexes 
Allow from all 
IndexOptions FancyIndexing 
</Directory> 

Alias /media/ "/Library/Python/2.7/site-packages/django/contrib/admin/media/" 
<Directory "/Library/Python/2.7/site-packages/django/contrib/admin/media"> 
Order allow,deny 
Options Indexes 
Allow from all 
IndexOptions FancyIndexing 
</Directory> 

WSGIScriptAlias /walble "/Users/David/Dropbox/sites/walble/apache/walble.wsgi" 

<Directory "/Users/David/Dropbox/sites/walble/apache"> 
Allow from all 
</Directory> 

walble.wsgi

import os 
import sys 

sys.path.append('/Users/David/Dropbox/sites/walble') 
sys.path.append('/Users/David/Dropbox/sites') 

os.environ['DJANGO_SETTINGS_MODULE'] = 'walble.settings' 

import django.core.handlers.wsgi 
application = django.core.handlers.wsgi.WSGIHandler() 

httpd.conf,我啓用 LoadModule wsgi_module libexec/apache2/mod_wsgi.so,然後加入以下行。

Include /Users/David/Dropbox/sites/walble/apache/apache_django_wsgi.conf

我重新啓動Apache和然後在瀏覽器我http://localhost/walble類型,但我得到像這樣

Forbidden 

You don't have permission to access /walble on this server. 

Apache/2.2.20 (Unix) DAV/2 mod_wsgi/3.3 Python/2.7.1 PHP/5.3.6 with Suhosin-Patch Server at localhost Port 80 

什麼我可能是做錯了任何建議被禁止的消息?

回答

0

這是一個常見的權限問題。 Apache用戶對walble.wsgi文件沒有執行權限。

+0

如何給這個文件的Apache權限? – David 2012-02-01 15:26:31

+1

請觀看演示http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations,其中解釋了此錯誤以及如何設置權限。 – 2012-02-02 12:24:15

相關問題