Django is a Python web framework which allows rapid development of website by following the Model-View-Controller architecture.

The Python language interpreter is installed by default on Ubuntu server. Therefore, you need not worry about installing python.

After python is installed, the recommended way of installing django is to use virtualenv to manage the django installation. Therefore, you need to have pip (used to install and manage python packages) and virtualenv installed first. Here goes for the steps:

  1. (For Ubuntu Server 12.04 LTS) The apt-get repository does not contain the latest version of pip in Ubuntu Server 12.04 LTS. Therefore we will download and install pip manually. For Ubuntu Server 14.04 LTS and above, skip this step and proceed to Step 2.

    Install setuptools and pip.

    1. In the command terminal, run:

      curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | sudo python -
      
    2. After the previous installation has completed, run:

      curl https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | sudo python -
      

    The files for setuptools and pip are automatically fetched and installed in the above commands.

  2. (For Ubuntu Server 14.04 LTS) If you have performed Step 1 above, you may skip this step.

    Install setuptools and pip directly using apt-get.

    1. In the command terminal, run:

      sudo apt-get update && sudo apt-get install -y python-setuptools python-pip
      

      apt-get will download and install pip.

  3. Install virtualenv.

    1. In the terminal, run:

      sudo pip install virtualenv
      

      If the error “The program ‘pip’ is currently not installed” occurs, check that the pip exectuble has been installed in the folder /usr/local/bin. Ensure also that the $PATH variable contains the path /usr/local/bin.

  4. Setup your virtual environment.

    1. In the terminal, run virtualenv .env . Replace .env with the folder where you want the virtual environment files to be generated.
    2. Then, run source .env\bin\activate to activate your virtual environment.
  5. Install Django.

    1. Now, you are in your virtual environement, and you will see a (.env) prefix on your command prompt. If you couldn’t find the prefix, check that you have executed the previous step correctly and you are using the same terminal.

    2. In the terminal, run:

      pip install django
      

    You have completed your Django installation on a virtual environment for your project. You can now continue to develop using Django!

For the same installation on Windows, please refer to my other post.

Reference: https://www.digitalocean.com/community/tutorials/common-python-tools-using-virtualenv-installing-with-pip-and-managing-packages