I'm using fabric to automate server configuration. You can easily write bunch of commands that setup nginx, supervisor, virtualenv, etc. I can post part of my fabfile:
@task
def setup_sys_installs():
"""
Note
----
You can always use 'sudo apt-get build-dep <python-package>' to
install some prerequisites for packages like gevent or lxml.
"""
print('=== SETUP LIBRARIES ====')
sudo('apt-get -y update')
sudo('apt-get -y install python-virtualenv python-pip python2.7 mercurial')
# you need this to pip install any compilled library
sudo('apt-get -y install python-dev build-essential')
# you need this need this to pip install gevent
sudo('apt-get -y install libevent-dev')
# you need this need this to pip install psycopg2
sudo ("apt-get -y install libpq-dev")
# you need this need this to pip install lxml
sudo('apt-get -y install libxml2-dev libxslt-dev')
# you need this need this to pip install m2crypto
sudo('apt-get -y install swig')
@task
def sync_virtualenv():
with cd(env.PROJECT_DIR):
cmd = "%s/bin/pip install -r requirements/production.txt" % (env.VENV,)
sudo(cmd, user=env.VENV_USER)
@task
def setup_virtualenv():
print('=== SETUP VIRTUALENV ====')
with cd(env.HOME):
sudo("virtualenv -p /usr/bin/python2.7 venv", user=env.VENV_USER)
sync_virtualenv()
Give me a comment, if you interested in more details.