Server Installation and Preparation
-
- create a Ubuntu Server 16.04 in AWS and login to the system
- sudo apt-get update
- sudo apt-get upgrade
- sudo apt-get dist-upgrade
- sudo vi /etc/hosts
127.0.0.1 localhost dok
-
- sudo vi /etc/hostname
dok
-
- sudo reboot
Postgres Installation
-
- sudo vi /etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
-
- wget –quiet -O – https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add
- sudo apt-get update
- sudo apt-get install postgresql-server-dev-9.6
Dokku Installation
-
- wget https://raw.githubusercontent.com/dokku/dokku/v0.7.2/bootstrap.sh;sudo DOKKU_TAG=v0.7.2 bash bootstrap.sh
Install PIP
-
- sudo apt-get install python3-pip
- pip3 install –upgrade pip
- pip3 install virtualenv
Create Django App
-
- mkdir hellodjango && cd hellodjango
- virtualenv venv
- source venv/bin/activate
- pip install django-toolbelt
- django-admin.py startproject hellodjango
- echo “web: gunicorn hellodjango.wsgi” > Procfile
- pip freeze > requirements.txt
- echo “venv” > .gitignore
Setup Git
-
- git config –global user.email “xxx@somedomain.net“
- git config –global user.name “someuser”
- git init
- git add .
- git commit -m “First Commit HelloDjango”
Upload Public Key for User
-
- ssh-keygen -t rsa
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
- cat ~/.ssh/id_rsa.pub | ssh ubuntu@52.52.212.236 “sudo sshcommand acl-add dokku hellodjango”
SHA256:yw60f5u5hXrWNfYG8KK+sbC1VihEIHVgsTINN2sVf1s
Add Remote
-
- git remote add production ubuntu@52.52.212.236:hellodjango
Edit Django Settings for Collectstatic Error
-
- vi hellodjango/settings.py
ALLOWED_HOSTS = ['52.52.210.250'] STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') # Extra places for collectstatic to find static files. STATICFILES_DIRS = ( )
Git Commit Changes
- git commit -m “Correct settings.py”
- git push master production
Recent Comments