2014-01-06 78 views
1

我有一个项目使用Django,我试图在运行OS X Server(10.9)的机器上的本地网络上部署Django。我可以使用项目的manage.py脚本在本地运行它,并拥有所有依赖关系和所有内容,但我一直在努力通过Server.app将它作为常规网站运行。下面是配置文件在服务器上的Web应用程序所需要的项目,都指向实际代码:在OS 10.9服务器上部署Django

/Library/Server/Web/Data/WebApps/project/.../ 

(它实际上没有命名的项目,我保证):

/库/服务器/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中。问题是,我得到500错误在/私营/无功以下条目/日志/的Apache2/error_log中:

[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。至少它在调用我的代码,但我无法弄清楚这个系统路径问题。有任何想法吗?

+0

我不知道任何关于Server.app,但什么用户它运行?你说这个目录在你的PYTHONPATH中,但大概服务器没有像你那样运行。 –

+0

它以管理员帐户运行,我手动添加(导出)PYTHONPATH到我的.bash_profile。现在我想到了,是否还有另一个地方需要指定它,以便它可以被Apache识别而不是bash会话? – drodman

回答

2

昨天我刚刚用OS 10.9服务器设置了django 1.6.1。

文件/Library/Server/Web/Config/apache2/httpd_wsgi2.conf [..]

WSGIScriptAlias//Users/jens/Source/macmini/macmini/macmini.wsgi 

<Directory /Users/jens/Source/macmini> 
Order allow,deny 
Allow from all 
</Directory> 

[..]

文件/库/服务器/网络/配置/的Apache2 /webapps/com.apple.webapp.wsgi2.plist

[...]

<?xml version="1.0" encoding="UTF-7"?> 
<!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.wsgi2</string> 
     <key>displayName</key> 
     <string>Django 1.6.1 Setup at/</string> 
     <key>launchKeys</key> 
     <array/> 
     <key>proxies</key> 
     <dict/> 
     <key>installationIndicatorFilePath</key> 
     <string>/Users/jens/Source/macmini/macmini/macmini.wsgi</string> 
     <key>includeFiles</key> 
     <array> 
       <string>/Library/Server/Web/Config/apache2/httpd_wsgi2.conf</string> 
     </array> 
     <key>requiredModuleNames</key> 
     <array> 
       <string>wsgi_module</string> 
     </array> 
</dict> 
</plist> 

[...]

Propably值得注意我延的家庭directoty内安装的Django

[...]

macmini:macmini jens$ ls -l 
total 72 
-rw-r--r-- 1 jens staff  0 14 Jan 20:43 __init__.py 
-rw-r--r-- 1 jens staff 133 14 Jan 21:10 __init__.pyc 
-rwxr-xr-x 1 jens staff 482 15 Jan 09:43 macmini.wsgi 
-rw-r--r-- 1 jens staff 4384 15 Jan 17:15 settings.py 
-rw-r--r-- 1 jens staff 3902 15 Jan 17:16 settings.pyc 
-rw-r--r-- 1 jens staff 298 14 Jan 20:43 urls.py 
-rw-r--r-- 1 jens staff 413 14 Jan 21:53 urls.pyc 
-rwxr-xr-x 1 jens staff 466 14 Jan 23:46 wsgi.py 
-rw-r--r-- 1 jens staff 590 14 Jan 21:52 wsgi.pyc 

[...]

而且finaly的wsgi.py文件

[...]

""" 
WSGI config for macmini project. 

It exposes the WSGI callable as a module-level variable named ``application``. 

For more information on this file, see 
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/ 
""" 

import os 
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "macmini.settings") 

from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

[012]

确保您现在在Server.app内创建了一个虚拟站点。

干杯,延斯

+0

非常感谢。 – mikec