我有一个使用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。至少它调用了我的代码,但我无法弄清楚这个系统路径问题。有什么想法吗?
答案 0 :(得分:2)
我昨天刚安装了django 1.6.1和OS 10.9服务器。
文件/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>
[..]
File /Library/Server/Web/Config/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>
[...]
值得注意的是我在Jens的家庭直播中安装了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
[...]
最后是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()
[...]
确保您现在在Server.app。
中创建虚拟站点干杯,詹斯