Monday, 28 November 2011

Running Django on Fasthosts

Yes, you read that right. This post contains details of how to run Django application on Fasthsots.

You will need:

  1. A fasthosts linux hosting account with a MySQL database and SSH access, and with CGI enabled.
  2. A Centos 5.6 virtual machine to set everything up on.
On your new fresh Centos virtual machine, run the following:

yum install mysql-devel gcc

Download and extract the python source code:

tar xzvf Python-2.7.2.tgz
cd Python-2.7.2

Configure, make and install python:

make install

Now install setuptools:

tar xzvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
python install

This will allow us to use easy_install to install pip and virtualenv

easy_install pip virtualenv

Right, now log in to fasthosts via SSH, and run


This is your home folder. Back on your Centos box, create a folder using the exact path pwd gave you on fasthosts:

mkdir -p <folder>
cd <folder>

Now create self-contained python environment:

virtualenv --distribute --no-site-packages django

Activate the virtual environment:

source django/bin/activate

And you should now be able to install any packages you need for your application to run.

pip install django MySQL-python

You will also need the standard python libraries:

cp -R /usr/local/lib/python2.7/* django/lib/python2.7/

Copy your Django project to the django folder and scp to the root of you home folder on fasthosts.

scp -r django <user>@<host>:./

You should now be able to ssh into fasthosts and run syncdb.

source django/bin/activate
cd django/<app name>
python syncdb

Copy any media files to htdocs/media and htdocs/static as required.

Finally, you need just two more files. This .htaccess in htdocs folder:

RewriteEngine on
RewriteRule ^cgi-bin/ - [L]
RewriteRule ^static/ - [L]
RewriteRule ^media/ - [L]
RewriteRule ^(.*)$ /cgi-bin/django.cgi/$1 [QSA,L]

The final file you need is django.cgi to go in your cgi-bin. Instructions of what you need to change can be found here:


  1. Replies
    1. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts. Python Projects for Students Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account. Project Center in Chennai

  2. Good. I am really impressed with your writing talents and also with the layout on your weblog. Appreciate, Is this a paid subject matter or did you customize it yourself? Either way keep up the nice quality writing, it is rare to peer a nice weblog like this one nowadays. Thank you, check also virtual edge and free online registration software