我跟着django文档讨论了如何在mac osx lion上使用mod_wsgi https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/将django 1.4部署到apache,当我添加WSGIPythonPath指令时,apache无法重启。如果没有它,我的应用程序在路径中是不存在的。在日志中我收到一条错误,内容为
WSHIPythonPath不能在VirtualHost部分中出现
这是我的虚拟主机配置的样子
<VirtualHost *:80>
ServerAdmin jmured@gmail.com
DocumentRoot "/Users/jamo/code/work/projects/bfpd/fapp"
ServerName bfpd.dev
ServerAlias bfpd.dev
ErrorLog "/private/var/log/apache2/bfpd.dev-error_log"
CustomLog "/private/var/log/apache2/bfpd.dev-access_log" common
Alias /static/ /Users/jamo/code/work/projects/bfpd/fapp/fapp/static/
<Directory /Users/jamo/code/work/projects/bfpd/fapp/fapp/static>
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride All
Order allow,deny
Allow from all
IndexOptions FancyIndexing
</Directory>
WSGIScriptAlias / /Users/jamo/code/work/projects/bfpd/fapp/fapp/wsgi.py
WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/
<Directory /Users/jamo/code/work/projects/bfpd/fapp/fapp>
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
我做错了什么???
答案 0 :(得分:10)
我修好了。
WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/
应该在http.conf
答案 1 :(得分:6)
如nemesisfixx的评论中所述,并由原始问题中的错误指定:
WSHIPythonPath不能在VirtualHost部分中出现
在VirtualHost之外移动WSGIPythonPath解决了Apache在OS X服务器上崩溃的问题。
$ cat sites/0000_any_80_mysite.com.conf
WSGIPythonPath /Library/Server/Web/Data/Sites/mysite/django-app:/Users/owen/.virtualenvs/mysite:/Users/owen/.virtualenvs/mysite/lib/python2.7/site-packages
<VirtualHost *:80>
ServerName mysite.com
ServerAdmin admin@example.com
DocumentRoot "/Library/Server/Web/Data/Sites/mysite/site"
...
WSGIScriptAlias /api /Library/Server/Web/Data/Sites/mysite/django-app/mysite/wsgi.wsgi
...
<VirtualHost>
我需要花很多时间才能让路径正确(包括site-env的完整路径,我最初认为在添加virtualenv顶级后会自动包含这些路径)。