Installing Django 1.5.1 with python 2.7.4 on Bluehost

First SSH Into your account (using putty, or terminal if you are on linux) where we will start by moving to our home directory (~) and creating a directory for the latest python.

cd ~
mkdir python27
wget http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tgz
tar xzvf Python-2.7.4.tgz
cd Python-2.7.4
./configure -prefix=/homeX/your_username/python27 --enable-unicode=ucs4
make
make install

We then add this python directory to our PATH environment variable and load it

sed -i '$ aPATH=/homeX/your_username/python27/bin:$PATH' ~/.bashrc
cd ~
source .bashrc

This will direct all ‘python’ commands to the python installation we just set-up.

(It is recommended that most users ignore the following: If you are using the built-in python for any reason, to have both simultaneously simply rename python27/bin/python to python27/bin/python27 and from here on out replace every instance of ‘python’ with ‘python27’.)

Now you can pause and test by typing

python

you should receive output like the following

Python 2.7.4 (default, Apr 14 2013, 08:29:07)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Now that we have python up and running lets start installing Django and its dependencies

  • Setuptools – prerequisite for pip
  • Pip – Python package manager
  • Flup – Python library for dealing with FastCGI

INSTALL SETUPTOOLS

cd ~
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar xzvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
python27 setup.py install

INSTALL PIP

cd ~
wget https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz
tar xzvf pip-1.3.1.tar.gz
cd pip-1.3.1
python27 setup.py install

INSTALL FLUP

pip install flup

Now to Install Django 🙂

pip install Django

If you need to interface with any databases you can add them with the optional lines below

//for Mysql
pip install MySQL-python
//for Postgresql
pip install psycopg2

Congrats! Django is now setup on your server. You can confirm by typing

django-admin.py

 

This Post Has 3 Comments

  1. I followed this guide but at the end I was unable to use psycopg2 due to wsfgi being compiled for python 2.6.6

    Then I removed all python2.7.4 and did again all these steps but with python 2.6.6 and all is working fine now.

  2. I am getting an error on entering this command:
    ./configure -prefix=/homeX/your_username/python27 –enable-unicode=ucs4
    The error msg is :
    checking for –enable-universalsdk… no
    checking for –with-universal-archs… 32-bit
    checking MACHDEP… linux2
    checking EXTRAPLATDIR…
    checking machine type as reported by uname -m… x86_64
    checking for –without-gcc… no
    checking for gcc… no
    checking for cc… no
    checking for cl.exe… no
    configure: error: in `/home/zealexai/src/Python-2.7.3′:
    configure: error: no acceptable C compiler found in $PATH
    See `config.log’ for more details

    How can i install GCC once I ssh to my account? Please help. Thank you,

    1. Nevermind, the hosting provider din’t supported it.

Leave a Reply

Close Menu
%d bloggers like this: