The main difficulty in deploying Django sites is the root access requirement.
But if you can modify the vhost file at your will, there is no problems.
However if you can't, you're in for a whole lot of fun.
My hosting partner use Plesk to administer hosting accounts, which means
almost every configs are generated by Plesk. So any changes to those configs
might get overwritten or worst, fuck up Plesk.
For the last year I've used a .htaccess file to set the python handler.
With a rewrite rule and some urls/config tweaks it was possible to get the site up and running.
The only downside was that the .htaccess needed a directory to be parsed, which means
I couldn't use the document root to serve a Django site. So I ended up having to put an URL prefix
before each of the urls.
To be honest, it was a co-worker at the time who tested different approaches
and found out it was the only way to go if we couldn't change the vhosts directives.
Now I have my own company and today I was launching the first website we produced.
I was about to use a similar hack to get Django working with Plesk, but the URL prefix really bugged me.
I think it's unprofessional and I had the feeling Plesk wasn't that rigid.
Two Google searches later my problem was solved.
It turns out Plesk does allow overriding vhost directives and quite easily that is.
Just create or edit a vhost.conf file in the right directory;
sudo vim /home/www/vhosts/yourdomain.com/conf/vhost.conf
Then simply add your vhost directives:
ServerAdmin "bob@yourdomain.com"
DocumentRoot /var/www/vhosts/yourdomain.com/httpdocs
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
...
Then you just have to refresh Plesk's config and restart apache:
/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=yourdomain.com
/etc/init.d/httpd graceful
Et voila.
no comments :|