- Login to Django's administration page.
- Select
Authentication and Authorization
›Users
. - Select users using checkbox.
- Select Action
Set user as teacher
. - Click
Go
.
-
Clone the repository
git clone https://github.com/MVISGuidance/production MVISGuidance cd MVISGuidance/
-
Setup environment variables (
.env
) if necessary.DJANGO_SETTINGS_MODULE = "main.setting.production" DJANGO_SECRET_KEY = "<django secret key>" DJANGO_HOSTNAME = "<deployment url>" EMAIL_HOST = "<email host>" EMAIL_HOST_USER = "<username for email host>" EMAIL_HOST_PASSWORD = "<password for email host>"
-
Setup and activate virtual environment with
virtualenv
.python -m virtualenv venv source venv/bin/activate pip install -r requirements.txt
-
Setup Django
python manage.py collectstatic python manage.py migrate
-
Setup gunicorn service (
/etc/systemd/system/MVISGuidance.service
).[Unit] Description=gunicorn daemon After=network.target [Service] User=root Group=www-data WorkingDirectory=<path to project>/backend ExecStart=<path to project>/venv/bin/gunicorn \ --access-logfile - \ --workers 3 \ --bind unix:/run/MVISGuidance.sock \ main.wsgi:application [Install] WantedBy=multi-user.target
-
Setup gunicorn socket (
/etc/systemd/system/MVISGuidance.socket
).[Unit] Description=gunicorn socket [Socket] ListenStream=/run/MVISGuidance.sock [Install] WantedBy=sockets.target
-
Enable the gunicorn and check its status.
sudo systemctl daemon-reload sudo systemctl start MVISGuidance sudo systemctl enable MVISGuidance sudo systemctl status MVISGuidance
-
Setup nginx (
/etc/nginx/sites-available/MVISGuidance
).server { listen 80; server_name '<server's IP address>'; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /var/www/MVISGuidance; } location /media/ { root /var/www/MVISGuidance; } location / { include proxy_params; proxy_pass http://unix:/run/MVISGuidance.sock; } }
-
Enable nginx and check status.
sudo ln -s /etc/nginx/sites-available/MVISGuidance /etc/nginx/sites-enabled sudo nginx -t
-
Restart nginx and open up the firewall to normal traffic on port 80
sudo systemctl restart nginx sudo ufw allow 'Nginx Full'
-
Update packages.
sudo apt-get update sudo apt-get upgrade
-
Move to the project folder and activate virtual environment.
cd MVISGuidance/ source venv/bin/activate
-
Pull the update.
git pull https://github.com/MVISGuidance/production
-
Setup environment variables (
.env
) if necessary. -
Update requirements and setup django.
pip install -r requirements.txt python backend/manage.py collectstatic python backend/manage.py migrate
-
Restart gunicorn
sudo systemctl daemon-reload sudo systemctl restart MVISGuidance
- https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
- https://djangocentral.com/deploy-django-with-nginx-gunicorn-postgresql-and-lets-encrypt-ssl-on-ubuntu/
- https://www.askpython.com/django/deploying-django-project-on-vps
See Contributing Guideline for more details.