+2347067162698
tclassified.com@gmail.com

Digital Ocean Django Deployment

Educational Technology and ICT

Created with Sketch.

Digital Ocean Django Deployment

DigitalOcean, Inc. is an American cloud infrastructure provider headquartered in New York City with data centers worldwide. DigitalOcean provides developers cloud services that help to deploy and scale applications that run simultaneously on multiple computers

create an account in digital ocean and login

put credit card details-it will not charge you for free trial

create droplet
ubuntu
standard
5$ per month
leave everything the way they are
click on create

you will get an email for your root user password

copy the password

go to your terminal and do the following


past the password you copied

change the password at the command prompt

that is the new user password

check the article digitalocean django ubuntu postgres tutorial
follow the articles instructions

on the article click on the initial setup guide link to learn how to create
a user with sudo priviledges


adduser austine
put a paswword
leave others as default
choose yes
to create the user

add user priviledges

usermod -aG sudo austine

close the second article and get back to the former one

Install the Packages from the Ubuntu Repositories for python 3

sudo apt-get update
sudo apt-get install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx


Create the PostgreSQL Database and User

sudo -u postgres psql

CREATE DATABASE onlineschool;
CREATE USER onlineschooluser WITH PASSWORD 'password123';
ALTER ROLE onlineschooluser SET client_encoding TO 'utf8';
ALTER ROLE onlineschooluser SET default_transaction_isolation TO 'read committed';
ALTER ROLE onlineschooluser SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE onlineschool TO onlineschooluser;
\q


Create a Python Virtual Environment for your Project
sudo -H pip3 install virtualenv

switch user to the new user

su austine

mkdir ~/onlineschool
ls /
ls /home/
ls /home/austine/
cd ~/onlineschool/

virtualenv onlineschoolenv

source onlineschoolenv/bin/activate

pip install django gunicorn psycopg2-binary

fetch your git project from git 
open a new terminal
git remote -v

you will see the address
copy it


git init
git remote add origin https://github.com/austainodedon/tclassifiedDjango.git
git pull origin master

pip install -r requirements.txt

push and pull as you make changes

settings.py

ALLOWED_HOSTS = ['206.189.199.2', 'tclassified.herokuapp.com', '127.0.0.1']

replace the sql database with postgres


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'onlineschooluser',
        'USER': 'onlineschool',
        'PASSWORD': 'password123',
        'HOST': 'localhost',
        'PORT': '',
    }
}

do the static roots

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

in your digital ocean command interface run migrations

python manage.py makemigrations
python manage.py migrate

python manage.py createsuperuser

python manage.py collectstatic

sudo ufw allow 8000

python manage.py runserver 0.0.0.0:8000

http://206.189.199.2:8000

Leave a Reply

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

Open chat