我一直试图让mod_wsgi在Mac OS X服务器上运行,而且我绝对没有运气。我已经将LoadModule语句添加到httpd.conf中,并且我已经包含以下文件:
apache_django_wsgi.conf:
WSGIDaemonProcess django
WSGIProcessGroup django
Alias /plagtest/ "/Users/plagtest/myproject/"
<Directory "/Users/plagtest/myproject/">
Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</Directory>
WSGIScriptAlias /plagtest "/Users/plagtest/myproject/apache/myproject.wsgi"
<Directory "/Users/plagtest/myproject/apache">
Allow from all
</Directory>
这是我的WSGI文件:
myproject.wsgi:
import os
import sys
paths = [ '/Users/plagtest/myproject',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
'/Users/plagtest',
]
for path in paths:
if path not in sys.path:
sys.path.append(path)
sys.executable = '/usr/local/bin/python2.7'
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我可以很好地重启Apache,但是当我浏览到localhost / plagtest /时会出现找不到的文件,这就是我在错误日志中得到的内容:
File does not exist: /Library/WebServer/Documents/plagtest/
我并不完全熟悉Apache,我确信它可能非常简单,但我不能在我的生活中找到一个解决方案。对此事的任何帮助将不胜感激。
答案 0 :(得分:2)
看起来你有两个相同路径的别名。所以你有一个重复。删除:
Alias /plagtest/ "/Users/plagtest/myproject/"
<Directory "/Users/plagtest/myproject/">
Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</Directory>
如果没有媒体别名,django手册建议使用HTTP conf:
WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Order allow,deny
Allow from all
</Files>
</Directory>