Django Installation

 

Django is an open source free web designing application framework which has been developed using python. In this tutorial, we are going to guide you on how to install Djano on centos server.

There are 3 methods to install Django on your server. They are mentioned in the following.

1) Installing Django globally through epel packages.

2) Installing Django globally through PIP.

3) Installing Django using virtualenv.

 

Installing Django globally through epel packages 

This is the easiest way to install Django on your server from epel repositories.

1) First, you will have to install epel repositories on the server, you can install the epel repository by running the following command.

yum install epel-release

2) Then run the below command to install Django.

yum install python-django

3) Once the installation has been completed you can check whether it has been successfully installed on the server by running the following command.

django-admin –version

1.6.11.7

In return, if you get the above version then we can confirm that Django installation was a success. But Django packages available through epel would be an outdated version.

 

Installing Django globally through PIP

If you need to install the latest version of Django, then the best method would be the installation through PIP. PIP is a package manager for python packages and pip command is used to install the python package Django.

1) First, install epel-release repository package by running the following.

Yum install epel-release

2) Run the following command to install pip on the server.

Yum install python-pip

3) Once you have installed PIP, then install Django using the pip.

Pip install django

4) Now to verify the installation was a success, run the following command.

django-admin –version

1.8.19

From the output itself, you can see you have received the latest version of the Django and thus installation of Django through pip will get the updated version than the epel-release.

 

Installing Django using virtualenv

As we discussed before, if you opting for this method then first install pip using epel.

1) Install PIP using epel.

Yum install epel-release

2) Now the pip is installed. You can use it to install virtualenv. Run the following command to install virtualenv using pip

pip install virtualenv

3) For each project, you can create a separate virtual environment for it. We can create a new directory and then make a virtual environment on it.

mkdir  -p /home/project

cd /home/project

4) To create a virtual environment in this directory, run the following command.

virtualenv newenviron

Running the above command will create an isolated environment on this directory and we have named it as newenviron

5) Now we are going to install the packages into this isolated environment, you must activate the isolated environment it by typing:

source newenviron/bin/activate

The above command should change your prompt and will reflect into a virtual environment. which would something look like

(newenviron)username@hostname:~/newproject$.

6) In this new environment, you can use pip to install Django.

pip install django

The above command will install the Django on this isolated environment and you can verify the installation is a success by typing:

django-admin –version

1.7.5

To leave from this virtual environment you can type the deactivate command as shown below.

Deactivate

Now you have exited from the virtual environment and your prompt should revert to the normal display.

 

If you need any further help, please do reach our support department.

 

Leave a Reply