Yes, you read that right. This post contains details of how to run Django application on Fasthsots.
You will need:
- A fasthosts linux hosting account with a MySQL database and SSH access, and with CGI enabled.
- 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
Configure, make and install python:
Now install setuptools:
tar xzvf setuptools-0.6c11.tar.gz
python setup.py 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>
Now create self-contained python environment:
virtualenv --distribute --no-site-packages django
Activate the virtual environment:
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.
cd django/<app name>
python manage.py 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:
RewriteRule ^cgi-bin/ - [L]
RewriteRule ^static/ - [L]
RewriteRule ^media/ - [L]
RewriteRule ^(.*)$ /cgi-bin/django.cgi/$1 [QSA,L]