How to Install Django on an Ubuntu 16.04 VPS

Django is a free and open source, Python-based web application framework. It is a set of useful components that help developers to easily and quickly create their applications. Django is built and maintained by experienced developers and used by some of the world’s biggest companies and governments. Also, some of the most popular websites such as Instagram, Mozilla, Pinterest, The Washington Times and Disqus are using Django.

Django has tons of great features such as the following

  • Extremely Fast: Designed for quickly creating applications from concept to completion.
  • Fully Loaded – Django includes a lot of extras that can help you handle common Web development tasks, such as user authentication, content administration, site maps, RSS feeds, and many more tasks — right out of the box.
  • Very Secure – Django takes security seriously and helps developers avoid many common security mistakes, such as SQL injection, cross-site scripting, cross-site request forgery and clickjacking. Its user authentication system provides a secure way to manage user accounts and passwords.
  • Easily Scalable – Some of the largest and busiest sites are using Django’s ability to quickly and flexibly scale to meet the heaviest traffic demands.
  • Incredibly Versatile – Companies, organizations, and governments have used Django to build all sorts of things — from content management systems to social networks to scientific computing platforms.

In this tutorial, we will show you how to install Django on an Ubuntu 16.04 VPS through pip.

First of all login to your Ubuntu VPS as user root

ssh root@IP

It is a good practice to always update all installed packed on the server to the latest version. So once you are logged in, make sure that all packages are updated

apt-get update && apt-get upgrade

The best way to install Django globally is by using the Python package manager (pip). This way you will always install the latest available version of Django on your server.

Install pip on your server by executing the following command

apt-get install python-pip

Or you can use Python3, as recommended by Django.

apt-get install python3-pip

You can find more detailed information about the pip installation in one of our previous blog posts.

Check if pip is successfully installed

# pip -V
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)

or for Python 3 run

# pip3 -V
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)

Now, you can install Django with one single command

pip install django

or if you are using Python 3

pip3 install django

Check if Django is successfully installed on your server

django-admin --version
1.10.5

If you receive the following warning that you are using an old pip version

You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

You can go ahead and update it

pip install --upgrade pip

 

Source