我一直试图让 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 并不完全熟悉,而且我确信它可能非常简单,但我终生无法在网上找到解决方案。在这件事上的任何帮助将不胜感激。