Django Hosting in Production

Create a Djnago project and Deploy it in production ..Just read along

Now install python3 and libapache2-mod-wsgi-py3

sudo apt-get update
sudo apt-get install python3
sudo apt-get install python3-pip
sudo pip3 install django
sudo apt-get install apache2
sudo apt-get install python3-setuptools
sudo apt-get install libapache2-mod-wsgi
sudo apt-get install libapache2-mod-wsgi-py3

go to
cd /var/www
and create a project mysite

sudo django-admin startproject mysite

you can install tree as to list all file in a dir

sudo apt-get install tree
tree .

Note:In find the line and replace it.It allows all host to access the Django project


cd mysite
python3 migrate
python3 runserver

go /etc/apache2/sites-available/ and edit 000-default.conf

cd /etc/apache2/sites-available/
sudo nano 000-default.conf
delete all contenet of that file and write

go to apache2 and edit apache2.conf

cd /etc/apache2
sudo nano apache2.conf

In Lastline add
WSGIPythonPath /var/www/mysite

Give proper permission to logs folder

cd /var/www
mkdir logs
sudo chmod 777 logs

and for CRUD of sqlite

sudo chgrp -R www-data /var/www/mysite
sudo chmod -R g+rwx /var/www/mysite

Now restart apache2 to see that works

sudo service apache2 restart

go to localhost and see that works
For more info

Leave a Reply

Your email address will not be published. Required fields are marked *