I want to run my Django website on OS X Server 3.2.1 running on Mavericks.
These more detailed considerations arise from my question.
- Can I deploy into OS X Server 3.2.1 without interfering with the reliability of OS X Server's own apps?
- Can I use the Server App's GUI to install new sites and manage existing ones?
- Can I use Django as a web app that I can 'bind' to other websites in the manner of OS X Server's "hello world" python web app?
- Can I use different python versions and use virtualenvs to manage package versions?
- Can I use UNIX Domain Sockets for interprocess communication between OS X Server's http server and a wsgi server like you can between Nginx and Gunicorn?
- Can I use Fabric to automate Django deployment to OS X Server?
Best Answer
wrt the issues above:
proxies
section of the plist for your web app in OS X Server's../apache2/webapp
directory is all-or-nothing. e.g. You can't Include aProxyPass /static/ !
in the right place for it to have effect.The approach I took:
.conf
file in OS X Server's../apache2/other
directory where it will be left alone by the Server app.Example code:
.conf for Django virtual server
This is adapted directly from the file that OS X Server generates from its GUI with these main differences:
ProxyPreserveHost
is off by default.ProxyPass /static/ !
prevents the Alias directive from being ignored. I found that, when including this directive using the Apple-recommended web app .plistincludeFiles
section, the Included lines were in the wrong place to have the desired effect.sed
your SITENAME and PORT:LaunchDaemon plist for Gunicorn wsgi server
sed
your SITENAME; REVERSED_SITENAME and PORT:Snippet from the OS X Server's
.bash_exports
Shows virtualenv paths specified by the virtualenvwrapper environment variables
Snippet from the Fabric automation file
fabfile.py
Shows:
The target paths - the directories where your configuration files will end up;
The commands to activate the Django site in the final steps in deployment