The blogosphere discussed the headache of deployment for modern Web Framework on shared hosting recently in couple weeks ago. This HOWTO documents the bumps and workaround in deploying Django to Jumpline’s VDS(Virtual Dedicated Servers) hosting.
Compared with the ironclad shared hosting, VDS provides SSH access, and private Apache server. Jumpline’s plan is also shipped with mod_python(python 2.5) and write access to PYTHON/site-package and /usr/local/bin, that make the whole process less painful.
Setup the VirtualHost
Add a sub-domain as
planet.kunxi.org in VDS console as our testbed.
Install Django SVN
It is a pity that Subversion is not installed in the
chroot jail. In fact the
Subversion hosting is a premium feature you need to pay for. Anyway, we can just
check out the code in the local machine, then copy it back to the server. In the
python setup.py build python setup.py install --prefix=/home/lib
If you happen not to have write privilege PYTHON/site-package, you may consider
--prefix to override the default installation path, then add the prefix to
PYTHONPATH environment variable.
Setup the mod_python
Load mod*python in
LoadModule python_module modules/mod_python.so
As the name suggests,
planet.kunxi.org is a feed aggregation portal based upon
FeedJack, some enhancement are in plan to scratch the etch, now it is just
mere a simple deployment:
<VirtualHost *:80> ServerName planet.kunxi.org DocumentRoot /var/www/planet SetHandler python-program PythonHandler django.core.handlers.modpython PythonDebug On PythonPath "['/home/projects'] + sys.path" SetEnv DJANGO_SETTINGS_MODULE feedpipe.settings <Location "/media"> SetHandler None </Location> <Location "/static"> SetHandler None </Location> </VirtualHost>
/static are set to host static media contents.
/media is mere a
soft symbol link to
django/contrib/admin/media. We also link
/static/feedjack to feedjack’s media files as FeedJack’s document suggests.
Here is the
MEDIA_ROOT = '/var/www/planet/static' MEDIA_URL = '/static/' ADMIN_MEDIA_PREFIX = '/media/'
Restart httpd, done.