Install Django framework using pip

Posted under » Django on 06 April 2021

When you install LAMP, php is installed with apache and mysql but in django you have to install them individually. I do not think you want to use SQLite or the built in web server that uses port 8080. You can also use Nginx but it is not recommended because of the slower performance.

First you need to install Python Apache Mod_wsgi. The mod_wsgi is an Apache module used to serve Python scripts over HTTP.

You should then install venv.

While under the activated environment, you may then install Django 4.2 LTS by

(bri) ubuntu@hornet:~$ pip install Django==4.2
(bri) ubuntu@hornet:~$ Successfully installed Django-4.2 asgiref-3.6.0 sqlparse-0.4.3

Note : Do not install as SUDO or root because it will break packages.

You may note that you can select the version number of your choice. However you should use the LTS version of Django 3.2 is the way to go while 4.2 LTS is just available in 2023.

If you want to check the Django version, open a Python console and type

>>> import django
>>> django.VERSION
(3, 1, 5, 'final', 0)

Or simply.

$ django-admin --version

Then you need to install the MySQLclient as I don't assume you will use sqlite.

Now you may proceed to start a django website.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS data