9

我遵循了 django 文档,了解如何在 mac osx lion 上使用 mod_wsgi https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/将 django 1.4 部署到 apache 以及当我添加 WSGIPythonPath 指令时 apache cant重新启动。但没有它,我的应用程序在路径中不存在。在日志中,我收到一条错误消息

WSGIPythonPath 不能出现在 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>

我究竟做错了什么 ???

4

2 回答 2

11

我修好了它。 WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/ 应该在http.conf

于 2012-08-29T21:43:50.260 回答
6

正如 nemesisfixx 的评论中所述,并由原始问题中的错误指定:

WSGIPythonPath 不能出现在 VirtualHost 部分中

将 WSGIPythonPath 移到 VirtualHost 之外解决了 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 顶层后会自动包含它)。

于 2014-08-14T11:07:48.420 回答