Getting Ubuntu 12.04 LTS, Django, and Heroku to all play nicely together

Personally, I used VMWare Workstation 8 to host my Ubuntu machine, so I will include some instructions for that as well.

 Part 1: Setup

Open: C:\ProgramData\VMware\VMware Workstation\config.ini (Windows 7)

Add the following:

prefvmx.minVmMemPct = "100" 
mainMem.useNamedFile = "FALSE" 
mainMem.partialLazySave = "FALSE" 
mainMem.partialLazyRestore = "FALSE"

Note: This will prevent a long shutdown process for your vm.

  1. Install ubuntu 12.04 LTS

  2. After boot, login (command line), and enter the following:

sudo mv /etc/issue.backup /etc/issue

sudo mv /etc/rc.local.backup /etc/rc.local

sudo mv /opt/vmware-tools-installer/lightdm.conf /etc/init

Note: This gets you past the issues with VMWare Tools Easy Install

sudo shutdown -h 0

  1. Make sure settings of vm set cd / floppy to physical

  2. Install vmware tools & reboot (optional)

  3. Update Ubuntu

sudo apt-get update && sudo apt-get dist-upgrade -y

  1. Reboot

 Part 2: Software Install

sudo apt-get install build-essential linux-headers-$(uname -r) git vim python-setuptools python-virtualenv

easy_install pip

sudo apt-get install rubygems1.9.1 libopenssl-ruby1.9.1

sudo gem install addressable

sudo gem install heroku

sudo gem install foreman

ssh-keygen -t rsa

mkdir -p ~/projects && cd ~/projects

sudo apt-get install libpq-dev python-dev

sudo apt-get install postgresql-server-dev-all

note: if psycopg2 still doesn’t install later on, do:

sudo apt-get install libconfig8

 Part 3: Django, Git, and Heroku

mkdir hellodjango && cd hellodjango

virtualenv venv –distribute

source venv/bin/activate

pip install django-toolbelt

django-admin.py startproject hellodjango

vim Procfile

Add the following:

web: gunicorn hellodjango.wsgi
foreman start

Test that your site is working by browsing to: localhost:5000 (or whatever the port is)

pip freeze > requirements.txt

vim .gitignore

Add the following:

venv
staticfiles
*.py[cod]

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
__pycache__

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

Edit hellodjango/settings.py. Add the following to the end:

# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES['default'] =  dj_database_url.config()
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Allow all host headers
ALLOWED_HOSTS = ['*']
# Static asset configuration
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

Edit hellodjango/wsgi.py. Replace it with:

from django.core.wsgi import get_wsgi_application 
from dj_static import Cling 
application = Cling(get_wsgi_application())

Then, run the following commands to initialize a git repository, and push your work to heroku.

git init

git add .

git commit -m “my django app”

heroku create

git push heroku master

  1. Log into heroku and rename your app.
  2. Browse to yourappname.herokuapp.com
 
0
Kudos
 
0
Kudos

Now read this

Dell XPS 9550 Mouse Lag only over Windows Desktop

Problem: Mouse lags when going over just the Windows desktop Hardware: Dell XPS 9550 Software: Windows 10 Solution: Task Manager -> Startup tab -> Disable Nvidia Capture Server Proxy; Restart your computer. Edit: More recently, I... Continue →