Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Deploying Django
Search
Brian Riley
February 22, 2012
12
850
Deploying Django
Presenting my setup at LA Django Meetup Feb. 21, 2012.
Brian Riley
February 22, 2012
Tweet
Share
More Decks by Brian Riley
See All by Brian Riley
Python for the Ruby Programmer
brianriley
0
200
Debugging your gunicorns
brianriley
2
160
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
17
950
Documentation Writing (for coders)
carmenintech
72
4.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Making Projects Easy
brettharned
116
6.3k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Language of Interfaces
destraynor
158
25k
Producing Creativity
orderedlist
PRO
346
40k
Agile that works and the tools we love
rasmusluckow
329
21k
Writing Fast Ruby
sferik
628
62k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
930
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Transcript
DEPLOYING DJANGO Brian Riley @btriley
DEPLOYING DJANGO or, you could just use Heroku Brian Riley
@btriley
WHO AM I? • been working with Django since 2006
• put Django into production many times, using just about every setup • work at EdgeCast
DEPLOYING IS CONFUSING • gunicorn or uwsgi • nginx or
apache • ? or ? or, you could just use Heroku
THE STACK
THE STACK: WEB SERVER • serving static media files •
proxying to dynamic applications “nginx is an HTTP and reverse proxy server”
NGINX CONF server { listen 80 default; server_name example.com; location
/static/ { root /path/to/project; } location / { proxy_pass http://127.0.0.1:8000; } }
THE STACK: WSGI SERVER “Gunicorn 'Green Unicorn' is a Python
WSGI HTTP Server for UNIX” ./manage.py run_gunicorn
UPSTART • comes with Ubuntu • automates startup/shutdown of processes
• use to manage your gunicorn service: service gunicorn [start | stop | restart]
description "Gunicorn for my Django application" start on runlevel [2345]
stop on runlevel [!2345] #Send KILL after 5 seconds kill timeout 5 respawn env PROJECT_ROOT="/opt/my_django_app" script exec python $PROJECT_ROOT/portal/manage.py run_gunicorn -- settings=settings.production --preload -w 16 --log-level debug --log- file /var/log/my_django_app/gunicorn.log -p /var/run/gunicorn.pid end script /etc/init/gunicorn.conf
AUTOMATION: FABRIC • command-line tool for running remote shell commands
• fab deploy
QUESTIONS? @btriley yes, you could just use Heroku