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 Setting.py find the line and replace it.It allows all host to access the Django project
ALLOWED_HOSTS = [‘*’]
cd mysite
python3 manage.py migrate
python3 manage.py 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
1 2 3 4 5 6 7 8 9 10 |
<VirtualHost *|:80> ServerName localhost ServerAlias 127.0.0.1 ServerAdmin akash073@gmail.com DocumentRoot /var/www/mysite WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py ErrorLog /var/www/logs/error.log CustomLog /var/www/logs/custom.log combined </VirtualHost> |
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