A fabric script to automatically install and configure django, fastcgi, and nginx for either development or deployment. This script was originally based on Eric Florenzano's "Deploying a Django Site" post written as part of Django Advent for Django 1.2.
-
fabric, this is a fabric script after all
$ pip install fabric
-
Install ubuntu, its expected that you have installed at least Ububtu JeOS and updated your system to the latest, eg:
$ sudo apt-get update $ sudo apt-get upgrade
-
Make sure ssh services are available to login to the ubuntu instance, eg:
$ sudo apt-get install ssh
-
optionally, push your ssh key to the server
$ fab push_ssh_cert
-
Copy the .fabricrc.sample file to .fabricrc
$ cp .fabricrc.sample .fabricrc
-
configure
.fabricrc
accordingly for your environment, at a minimum, you'll need to configure: django_user, django_pswd, django_site and nginx_media_root. -
Modify the
env.hosts
andenv.user
variables at the top offabfile.py
-
Execute the script
$ fab -c ./.fabricrc install
-
Now, browse to: http://yourhost.com/ and you should see "Congratulations on your first Django-powered page"
You now have installed django, fastcgi, and nginx with a django project
installed in $HOME/django_site
. You can activate your virtualenv with
$ su - django_user
$ source ~/virtualenvs/django_site/bin/activate
$ cd ~/django_site
Once your in django_site you can install additional apps and/or configure the django project to your needs.
-
Push your public ssh keys to the server
fab push_ssh_cert
-
Terminate the service
fab -c ./.fabricrc terminate
-
Launch the service
fab -c ./.fabricrc launch
-
Restart the service
fab -c ./.fabricrc restart
Some VPS providers customize their sources.list
, if you receive an error like Package nginx has no installation candidate
, make sure /etc/apt/sources.list
has the proper sources eg:
deb http://archive.ubuntu.com/ubuntu karmic main
deb-src http://archive.ubuntu.com/ubuntu karmic main
deb http://archive.ubuntu.com/ubuntu karmic-updates main
deb-src http://archive.ubuntu.com/ubuntu karmic-updates main
deb http://archive.ubuntu.com/ubuntu karmic-security main
deb-src http://archive.ubuntu.com/ubuntu karmic-security main
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ karmic universe
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic universe
deb http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe
and then make sure you update apt cache:
apt-get update