ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest technologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

Looking for Django or Node.js hosting? Try our service from £1.60 / month.

Get Django Hosting Get Node.js Hosting

How to Install Django Web Framework on CentOS 7

Django is a fully featured Python based web framework which helps in rapid development and clean design. Web frameworks like Django provide a set of tools which helps the developer to write the application faster as the framework takes care of the internal structure, thus the developer needs to take care of the application development only. Django is free and open source software.

Features of Django

Django is very popular python web framework tools because of these main features.

  • Development using Django is very fast as it is designed to help the developers to complete their application as quickly as possible.
  • Django comes with the tools which you can use to handle common web development tasks like user authentication, sitemaps, content administration, API and many more.
  • Django helps the developer to avoid common security mistakes like SQL injection, Cross site scripting, Clickjacking etc.
  • Its user authentication system provides a secure way to manage user accounts and passwords.
  • Django can be easily scaled to handle very heavy traffic.

We can install Django through various methods like installing through the packages available in default EPEL repository or installing through pip globally or installing through pip in Virtualenv. If we are installing it through packages available through the default EPEL repository then we may not get the latest version of software. If you choose to install it globally through pip then you will get the latest version of software. pip is a package manager tool for Python packages. pip will install Django globally for any user to use, global installs are less flexible compared to Virtualenv installs.

virtualenv is a Python package which is used to create and manage self contained virtual Python environments. Using this tool you can install Django in a single project directory or virtual environment without affecting the whole system. This will allow you to customise the need of different projects separately. Installation of Django using this method is recommended as it provides the most flexibility in building projects.

In this tutorial we are going to learn to install the latest version of Django web framework on CentOS 7.x server using pip globally and using pip with virtualenv.

In this guide we will be using a non root account to install Django. If you are logged in to your server using root account, omit using sudo command from all the commands.

Installing Django Globally using pip

First thing to do is to update the yum repository and add the EPEL repository in our system, as pip package is available in this repository. Execute the following command to do so -

    sudo yum -y update
    sudo yum -y install epel-release

Now you can install pipusing the following command -

    sudo yum -y install python-pip

After installation of pip you can install Django globally using the following command -

    sudo pip install django

You will get a successful message in terminal saying Successfully installed django-1.x.x. If you want to install any older version of Django instead of the latest version, you can execute the following command.

    sudo pip install django==x.x.x

Where x.x.x is the version you want to install. For example if you want to install Django version 1.8.6, you can use the following command -

    sudo pip install django==1.8.6

You can also check the version of Django by executing the following command in terminal -

    django-admin version

It will show you the installed version of Django.

Installing Django in Virtualenv Using pip

You can install Django on your system with virtualenv package. Update yum repository and add EPEL repository using the following command.

    sudo yum -y update
    sudo yum -y install epel-release

Now you can install pipusing the following command.

    sudo yum -y install python-pip

After installing pip you can install virtualenv using the following command.

    sudo pip install virtualenv

You will get successful message similar to shown below.

    Successfully installed virtualenv-15.0.2

Now start your new project by creating a directory. Once we have created the directory we can setup virtual environment inside the directory. Run the following command to create a new directory in home directory of user and move into the new directory.

    cd ~
    mkdir myproject
    cd myproject
myproject is an example name we have provided to our project directory, you can use any name instead of myproject. Now you can create your python virtual environment using the following command -
    virtualenv mydjangoproject
mydjangoproject is a sample name we have provided for our virtual environment, you can use any descriptive name instead of mydjangoproject. Once you execute the above command you will see following output.
    New python executable in /home/user/myproject/mydjangoproject/bin/python
    Installing setuptools, pip, wheel...done.

We now have local version of python along with local pip installed in our project directory. You can also view the files of our virtual environment using ls command. Now we will need to activate the virtual environment using the following command.

    source mydjangoproject/bin/activate

Now you should see that your terminal has now gone into virtual environment. You will see something similar to this.

    (mydjangoproject) [user@hostname myproject]$

Once we are in the virtual environment, we can install Django using pip by executing the following command.

    pip install django

If you want to install any older version of Django instead of the latest version, you can execute the following command -

    pip install django==x.x.x

You can verify the if Django is installed or not by checking the version of Django using the following command -

    django-admin version

You can always execute the following command to leave the virtual environment -


Whenever you want to go to your virtual environment, you can always change your directory to your project directory by executing cd ~/myproject and then activating your virtual environment by executing source mydjangoproject/bin/activate.

Creating a Django project

Now that we have Django installed we can create a sample project to start with. If you have installed Django globally using pip then use the following command to create a project.

    django-admin startproject myproject

The above commands will create your project and will add myproject directory. Within this directory it will create file which is a command line utility to help you manage your project. It will also create another directory with same name into the project directory. This is the directory in which the actual project files will be stored. There will be these four files created initially.

  • - An empty file to tell Python that directory should be considered as Python packages.
  • - A file containing the the configuration of your project.
  • - This file will contain the URL structure of your Django project.
  • - This file will help WSGI-compatible web servers to serve your project.

You can view the list of the files using ls command.

If you have installed Django on Virtual environment then you will need to activate the environment and then execute the following command to start a new project.

    django-admin startproject myproject .

This will create project files in the myproject directory within the project directory and the management script will be created in the project directory. Putting dot (.) at end is very important to create the project files in the same directory.

Now we will need to transfer the database of our project to SQLite database, execute the following command -

    python migrate

You will see following output once the command is successfully execute.

    Operations to perform:
      Apply all migrations: admin, contenttypes, auth, sessions
    Running migrations:
      Rendering model states... DONE
      Applying contenttypes.0001_initial... OK
      Applying auth.0001_initial... OK
      Applying admin.0001_initial... OK
      Applying admin.0002_logentry_remove_auto_add... OK
      Applying contenttypes.0002_remove_content_type_name... OK
      Applying auth.0002_alter_permission_name_max_length... OK
      Applying auth.0003_alter_user_email_max_length... OK
      Applying auth.0004_alter_user_username_opts... OK
      Applying auth.0005_alter_user_last_login_null... OK
      Applying auth.0006_require_contenttypes_0002... OK
      Applying auth.0007_alter_validators_add_error_messages... OK
      Applying sessions.0001_initial... OK

Now you will need to create an administrative user for your Django web based admin panel of your project. Execute the following command to do the same.

    python createsuperuser

You will need to provide a username, email and password for your administrative user.

Now you can run your development server to run your Django project. Execute the following command to do so -

    python runserver

This will start a local server on port number 8080. You will see following output on terminal -

    Performing system checks...

System check identified no issues (0 silenced). June 20, 2016 - 19:51:08 Django version 1.9.7, using settings 'myproject.settings' Starting development server at Quit the server with CONTROL-C.

Now you can go to the following web address to access your webserver using your favorite browser.


You will see something similar to this.

Now to access administrative dashboard go to following address -


You will see the login page of admin panel -

Enter the username and password you have created recently, and click Log in button. You will be now logged into Django admin panel, which will look similar to this.


In this tutorial we have installed Django web framework on CentOS 7.x, both globally and on a virtual environment using pip. Now you can easily deploy Django on CentOS 7.x and you can also create a sample Django project.

Looking for Django or Node.js hosting? Try our service from £1.60 / month.

View Plans