【发布时间】:2014-01-06 20:01:07
【问题描述】:
我有一个使用 Django 的项目,我试图在运行 OS X Server (10.9) 的机器上的本地网络上部署该项目。我可以使用项目的 manage.py 脚本在本地运行它并拥有所有依赖项和所有内容,但我很难通过 Server.app 让它作为常规网站运行。下面是服务端web应用所需要的项目的配置文件,全部指向实际的代码在:
/Library/Server/Web/Data/WebApps/project/.../
(我保证,它实际上并没有命名为项目):
/Library/Server/Web/Config/apache2/httpd_project.conf
WSGIScriptAlias /unity /Library/Server/Web/Data/WebApps/unity/unity/site.wsgi
/Library/Server/Web/Config/apache2/webapps/com.apple.webapp.project.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>com.apple.webapp.project</string>
<key>displayName</key>
<string>Daily Download</string>
<key>launchKeys</key>
<array/>
<key>proxies</key>
<dict/>
<key>installationIndicatorFilePath</key>
<string>/Library/Server/Web/Data/WebApps/project/project/site.wsgi</string>
<key>includeFiles</key>
<array>
<string>/Library/Server/Web/Config/apache2/httpd_project.conf</string>
</array>
<key>requiredModuleNames</key>
<array>
<string>wsgi_module</string>
</array>
我已经将它添加为 Server.app 中的网站。问题是 /private/var/log/apache2/error_log 中的以下条目出现 500 个错误:
[Mon Jan 06 14:55:21 2014] [error] [client 17.19.244.170] ImportError: Could not import settings 'project.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named unity.settings
这对我来说很奇怪,因为我已经将该目录添加到我的 PYTHONPATH 并且可以从 Python 提示符导入 project.settings。至少它在调用我的代码,但我无法弄清楚这个系统路径问题。有什么想法吗?
【问题讨论】:
-
我对Server.app一无所知,但它以什么用户身份运行?你说目录在你的 PYTHONPATH 中,但大概服务器没有像你一样运行。
-
它以管理员帐户运行,我手动将 PYTHONPATH 添加(导出)到我的 .bash_profile 中。现在我想了想,是否需要在另一个地方指定它,以便 Apache 而不是 bash 会话识别它?
标签: python django apache pythonpath osx-server