Background Image
Table of Contents Table of Contents
Previous Page  181 / 478 Next Page
Information
Show Menu
Previous Page 181 / 478 Next Page
Page Background

2.

apt-get nginx git python-pip

3.

pip install virtualenv

4. Add Nginx config for virtual host

5. Add Upstart job for Gunicorn

Deployment

1. Create directory structure in

~/sites

2. Pull down source code into folder named

source

3. Start virtualenv in

../virtualenv

4.

pip install -r requirements.txt

5.

manage.py migrate

for database

6.

collectstatic

for static files

7. Set DEBUG = False and ALLOWED_HOSTS in

settings.py

8. Restart Gunicorn job

9. Run FTs to check everything works

Assuming we’re not ready to entirely automate our provisioning process, how should

we save the results of our investigation so far? I would say that the Nginx and Upstart

config files should probably be saved somewhere, in a way that makes it easy to reuse

them later. Let’s save them in a new subfolder in our repo:

$

mkdir deploy_tools

deploy_tools/nginx.template.conf.

server

{

listen

80

;

server_name

SITENAME

;

location

/static

{

alias

/home/elspeth/sites/SITENAME/static

;

}

location

/

{

proxy_set_header

Host

$host

;

proxy_pass

http://unix

:/tmp/SITENAME.socket

;

}

}

deploy_tools/gunicorn-upstart.template.conf.

description

"Gunicorn server for SITENAME"

start on net-device-up

stop on shutdown

respawn

Automating

|

153