sudo apt update && apt install
. You can then create the directory for the project. This step doesn’t make a lot of difference
if done differently. We have used this structure:
-Project-name
-site
-logs
-public
-django
-auth
Now to retrieve files from github, git needs to be installed using sudo apt install git
. After the installation is complete navigate
to django directory and clone the repository from github using sudo git clone /github location/
. This assumes that the code is stored
in github.With this done we can start downloading the dependencies. Using sudo apt install python3-pip
will install pip3 which
is the package manager for python. Then using pip3 install virtualenv
with sudo pip3 install virtualenv which we will use to create
virtual environment in which we will download all of the python frameworks and libraries. Using source venv/bin/activate
will activate the
virtual environment. To deactivate it simply use the command deactivate. Now if you navigate to your project folder where requirements.txt
resides.Using pip3 install -r requirements.txt
will install all required frameworks and dependencies for the backend. Then navigate to settings.py
file add your ip address into allowed hosts. Then navigating to the frontend folder we will download all of the frontend related dependencies.
Here we will install nodejs and npm via sudo apt install nodejs npm
. After that is complete simply run sudo npm install
to install all required dependencies.
sudo apt install apache2 libapache2-mod-wsgi-py3
.
Then relocate into sites-available folder cd /etc/apache2/sites-available/
and open 000-default.conf with nano, sudo nano 000-default.conf
. Change it to look like the example below.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog /project_name/site/logs/error.log
CustomLog /project_name/site/logs/access.log combined
<Directory /path to directory containing wsgi.py/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess projectname python-path=<abs path to directory containing manage.py is> python-home=/project_name/venv
WSGIProcessGroup projectname
WSGIScriptAlias / /path to directory containing wsgi.py/wsgi.py
</VirtualHost>
Restart apache server with sudo service apache2 restart
.
python manage.py runserver
sudo npm start
celery -A tasks worker -l info
celery -A tasks beat -l info