Installing Django on Ubuntu Server
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:
(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.
In the command terminal, run:
After the previous installation has completed, run:
The files for setuptools and pip are automatically fetched and installed in the above commands.
(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.
In the command terminal, run:
apt-get will download and install pip.
Install virtualenv.
In the terminal, run:
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
.
Setup your virtual environment.
- In the terminal, run
virtualenv .env
. Replace .env with the folder where you want the virtual environment files to be generated. - Then, run
source .env\bin\activate
to activate your virtual environment.
- In the terminal, run
Install Django.
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.In the terminal, run:
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.
comments powered by Disqus