Quantcast
Channel: Welcome to my imagine!
Viewing all articles
Browse latest Browse all 4

Installing Django on Ubuntu Server 14.04

$
0
0

What is Django?

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Official website https://www.djangoproject.com/. Some of the famous web applications built using Django are:

  • Instagram

A photo sharing app for Android and iOS.

  • Matplotlib

A powerful python 2D plotting library.

  • Pinterest

A virtual pin board to share things you find on the web.

1.Installing Python

Generally you no need to install Python because Python was installed on most Linux OS by default. So now we can check our Python version. In this tutorial I use Ubuntu Server 14.04.

saikeo@ubuntu:~$ python --version
 Python 2.7.6
 saikeo@ubuntu:~$

We already have Python version 2.7.6 installed.

2. Installing Database

We will use SQLite as our database. SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed database engine in the world. To install SQLite use the following command.

saikeo@ubuntu:~$ sudo apt-get install sqlite

3. Install PIP and easy_install

  • pip is a package management system used to install and manage software packages written in Python. Many packages can be found in the Python Package Index (PyPI). Python 2.7.9 and later (on the python2 series), and Python 3.4 and later include pip (pip3 for Python 3) by default.
  • EasyInstall (easy_install) gives you a quick and painless way to install packages remotely by connecting to the cheeseshop or even other websites via HTTP. It is somewhat analogous to the CPAN and PEAR tools for Perl and PHP, respectively.

To install easy_install we use the following command.

saikeo@ubuntu:~$ sudo apt-get install python-setuptools

Before continue to next step we have to confirm that pip, easy_install and SQLite has been installed. To do so, use the following command to check it out.

saikeo@ubuntu:~$ sqlite -version
 2.8.17
 saikeo@ubuntu:~$ easy_install --version
 setuptools 3.3
 saikeo@ubuntu:~$ pip --version
 The program 'pip' is currently not installed. You can install it by typing:
 sudo apt-get install python-pip
 saikeo@ubuntu:~$

We will see that pip is not installed on our system yet. Use the following command to install pip.

saikeo@ubuntu:~$ sudo apt-get install python-pip

Now check pip version again.

saikeo@ubuntu:~$ pip --version
 pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
 saikeo@ubuntu:~$

4. Installing a virtual environment.

A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them.

So now we can install virtualenv by using the easiest way to install it by the following command:

sudo easy_install virtualenv

Now go to setting up the virtual environment.

Type the following command to create a folder using virtualenv. This folder can act as the virtual environment to contain Django.

saikeo@ubuntu:~$ virtualenv --no-site-packages django-user

The folder will be created under the directory which you are currently in. To start the virtual environment use the following command.

saikeo@ubuntu:~$ source django-user/bin/activate

If you see as the image below it’s mean our virtual environment is working!

Navigate to the folder django-user using the command.

(django-user)saikeo@ubuntu:~$ cd django-user/

5. Install Django Framework

To install Django Framework use the following command:

(django-user)saikeo@ubuntu:~/django-user$ easy_install django

We are done. Now Django is already install on your system. You also can check which version Django was install on your system by using the following command.

(django-user)saikeo@ubuntu:~/django-user$ python -c "import django; print(django.get_version())"

Enjoys!

 

Reference:

  1. https://www.djangoproject.com/
  2. https://www.sqlite.org/
  3. https://wiki.python.org/moin/EasyInstall
  4. https://en.wikipedia.org/wiki/Pip_%28package_manager%29

 

 


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images