[Gabriel Falcão] Hosting and deploying django apps on Dreamhost

About two years ago, I’ve signed up to Dreamhost. My goals were and still being to host my personal projects, websites and so on.

Once I am a Django web developer, one of my first actions were to create a django deployment setup, good and flexible enough. The time passed on and have been got new experiences, and the best desision, i think, was to create a new python sandbox, i mean, a customized python environment.

How is it possible ?

Simple! Just compiling python from scratch, with a fake root path (a prefix)

Anyway, the deployment process involves more variables, like setting both htaccess and dispatch files for each project, installing some basic modules such PIL and MySQL and so on…

So, i ever wanted to create a super duper script to do all that “dirty” work. And i did it last weekend!

I were working ia a freelance job and decided to create a subdomain to host test instance of them.

A new sandbox, ready to make my tests to create the super script.

So folks, i present you the brand new: django_dreamhost.sh :)

It’s composed by 4 files:

  • django_dreamhost.sh itself
  • djangify.template - a template with will become a script to setup new projects (htaccess and dipatch files, for instance)
  • htaccess.template - a template that will become the .htaccess of each project of yours
  • dispatch.template - will become the dispatch.fcgi for your projects as well

“But do i need to download all them ?”, of course NO!

You just download the main script, and he will do all do hard work!

“I wanna contribute, modify or do anything with that script, can I ?”, of course yes! All parts of the script are GPLv2 +

You can also always get the development version through git repository:

git clone http://git.nacaolivre.org/django_dreamhost

Don’t want to get all code, just the script ?

Download it at: http://gnu.gabrielfalcao.com/django_dreamhost/django_dreamhost.sh

What does that script do ?

He will do the following steps:

  1. Download Python, Django, Python-setuptools, Python-fastcgi to a directory called downloads
  2. Extract all
  3. Create a local root at $HOME/.myroot and the subdirs etc and usr
  4. Set the new bin path to you global path through bashrc and bash_profile
  5. Compile and install python to the new prefix: $HOME/.myroot/usr
  6. Install Django, rename django-admin.py to django-admin
  7. Setup your bash-completion to support django scripts
  8. Install the python modules above with the new python
  9. Install PIL and MYSQL modules through easy_install (setuptools)
  10. Download the template scripts to $HOME/projects/script_templates
  11. Replace the custom tags in templates
  12. Move the djangify.template to the new bin PATH: $HOME/usr/bin and give it execution permission

I thinks it’s all.

I currently use Fabric to help on deployment, and i have a quite smart basic setup for it to work with this dreamhost django environment, but it will be approached in the next blog post :)

See you, folks!