when configuring mod_wsgi for django 1.4 apache fails to start on mac osx after adding WSGIPythonPath to the virtual host config
我在django docs上关注了如何在Mac OS X Lion上使用mod_wsgi https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/以及在添加WSGIPythonPath指令apache cant时如何使用django 1.4将django 1.4部署到Apache 重新启动。如果没有它,我的应用程序在路径中不存在。 在日志中,我收到一条错误消息,内容为
WSGIPythonPath cannot occur within VirtualHost section
这是我的虚拟主机配置的样子
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <VirtualHost *:80> ServerAdmin [email protected] 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> |
我究竟做错了什么 ???
我修好了它。
应该在
如nemesisfixx的注释中所述,并由原始问题中的错误指定:
WSGIPythonPath cannot occur within VirtualHost section
将WSGIPythonPath移出VirtualHost可以解决Apache在OS X服务器上崩溃的问题。
1 2 3 4 5 6 7 8 9 10 11 | $ 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 [email protected] 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顶层后会自动包含该路径)。