Installing Django on GoDaddy Hosting

by Emmanuel D. on February 23, 2012

Most web developers wonder if Django is possible in GoDaddy hosting and it seems to be the issue of most users when it comes to Django is its compatibility with top domain and hosting provider such as GoDaddy. The aswer to the question whether Django can work in GoDaddy is definitely a big “Yes”. GoDaddy supports Ruby On Rails then there is no reason why it cannot support Django as well. Ruby On Rails is another CMS that uses Python as its core and GoDaddy has always an updated version of Python.

Unlike other CMS or Content Management System where it has a 1-2-3 clicks and intall like Fantastico, Django is not yet part of hosting installer package which I think it already should be there now since it is one of the top rising CMS. Django is basically a mesh of Python framework and MySQL database and both are present in GoDaddy hosting so installing Django in GoDaddy is a breeze.

Before you proceed with the installation, make sure you have the following:

1. GoDaddy Account, either unlimited hosting, deluxe or the basic account as long as with access to cPanel.

2. Python 2.4 or the latest. You can download it for free.

3. Django CMS.

Here Are The Steps To Install Django and Make Sure It Runs Smoothly:

Create a Directory for Your Python and add the Following code:

mkdir lib
cd lib/
mkdir python-packages
cd python-packages/
echo -e "\nexport PYTHONPATH=\$HOME/lib/python-packages:\$PYTHONPATH\n" >> ~/.bash_profile
source ~/.bash_profile

Install django. In the python-packages folder:

tar xfvz Django-0.96.5.tar.gz
mv Django-0.96.5/django/ .

Install MySQLdb. In the python-packages folder:

tar xfvz MySQL-python-1.2.0.tar.gz
mv MySQL-python-1.2.0/MySQLdb/ .

Try uploading your website via FTP and test the file below:

python manage.py syncdb

Deploying Your Website:

From the python-packages folder, download and install flup:

tar fxzv flup-1.0.2.tar.gz
mv flup-1.0.2/flup .
rm -r flup-1.0.2*

From your html folder, create a dispatch.cgi:

#!/usr/bin/python2.4
import sys, os
sys.path += ['/home/username/lib/python-packages']
sys.path += ['/home/username/some/path/to/a/djangosite/mywebsite']
os.environ['DJANGO_SETTINGS_MODULE'= 'mywebsite.settings'
from flup.server.fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
WSGIServer(WSGIHandler()).run()

Change both sys.path and mywebsite names. Chmod executable and try:

./dispatch.cgi

If it spits out a bunch of HTML, you’re almost home.

Redirect all traffic to dispatch.cgi. In the html folder create/edit the .htaccessfile:

RewriteEngine On
RewriteBase /
# folders with php & static content
RewriteRule ^(stats/.*)$ - [L]
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin-media/.*)$ - [L]
RewriteRule ^(favicon.ico)$ - [L]
RewriteRule ^(favicon.gif)$ - [L]
# everything else sent to django
RewriteRule ^(dispatch\.cgi/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.cgi/$1 [L]

And that’s it! You just successfully installed your Django CMS to GoDaddy hosting. If you have issues with Django with your GoDaddy account, you can send them a message and their tech support can surely help you.

Also, if you’re updating your site and need some help with storage or transfer of large files, try using YouSendIt.com. We’ve been using it for free thanks to this YouSendIt.com Promo Code we found.

Previous post:

Next post:

About |  Contact |  Sitemap |  Terms of Service |  Privacy