I have a project that uses Django that I'm attempting to deploy on a local network on a machine running OS X Server (10.9). I can run it locally with the project's manage.py script and have all of the dependencies and everything, but am struggling to get it running as a regular website through Server.app. Below are the configuration files for the project required by web applications on the server, all pointing to the actual code in :
/Library/Server/Web/Data/WebApps/project/.../
(it's not actually named project, I promise):
/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>
I've already added it as a website in Server.app. The issue is that I'm getting 500 errors with the following entry in /private/var/log/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
This is weird to me because I've added that directory to my PYTHONPATH and can import project.settings from the Python prompt. At least it's calling my code, but I can't figure out this system path issue. Any ideas?
I just setup django 1.6.1 with OS 10.9 Server yesterday.
File /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>
[...]
Propably noteworthy I installed django within the Home directoty of Jens
[...]
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
[...]
And finaly the wsgi.py file
[...]
"""
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()
[...]
Make sure that you now create a virtual site within the Server.app.
Cheers, Jens