Update aptitude
$ sudo apt-get update
$ sudo apt-get upgrade
Install necessary packages
$ sudo apt-get install build-essential
Install Python
$ sudo apt-get install python2.7-dev python-setuptools
$ sudo easy_install pip
Install git
$ sudo apt-get install git-core
Generate a new SSH key
$ ssh-keygen -t rsa -C "[email protected]"
Then add the key from ~/.ssh/id_rsa.pub to GitHub
Test the key by
$ ssh -T [email protected]
$ cd /
$ sudo mkdir web
$ cd web
$ sudo mkdir conf run logs
Install virtualenv and virtualenvwrapper
$ sudo pip install virtualenv virtualenvwrapper
Add the following to .bashrc
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
Create a new folder to keep all virtual environments
$ mkdir $HOME/.virtualenvs
Start a new terminal then create a new virtualenv by
$ mkvirtualenv [project name]
Install Supervisor
$ sudo easy_install supervisor
Create a new config file
$ echo_supervisord_conf > $HOME/supervisord.conf
$ sudo mv $HOME/supervisord.conf /web/conf/
Install Postgresql Server and Python library
$ sudo apt-get install postgresql python-psycopg2 libpq-dev
Create a new database and database's user
$ sudo -u postgres createdb [database_name]
$ sudo -u postgres createuser -SDRP [database_user_name]
Config pg_hba.conf file
$ sudo vim /etc/postgresql/9.1/main/pg_hba.conf
Then add the following to pg_hba.conf file let database user authenticated using password
local [database_name] [database_user_name] md5
Reload Postgresql server
$ sudo /etc/init.d/postgresql reload
Download nginx from its website
http://nginx.org/en/download.html
Install PCRE library (necessary for rewrite module)
$ sudo apt-get install libpcre3-dev
Extract nginx tar file then configure use the following commands
$ sudo ./configure --conf-path=/web/conf/nginx/nginx.conf
$ sudo make
$ sudo make install
The following is the default settings for nginx
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/web/conf/nginx"
nginx configuration file: "/web/conf/nginx/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
Run nginx by
$ /usr/local/nginx/sbin/nginx
Download uWSGI from
http://projects.unbit.it/uwsgi/wiki/WikiStart#Getit
Build uWSGI and copy to bin folder
$ sudo python uwsgiconfig.py --build
$ sudo cp uwsgi /usr/local/bin/
Run uWSGI in Emperor mode by
$ sudo uwsgi --emperor /web/conf/uwsgi
Install dependencies
$ sudo apt-get build-dep python-imaging
Symlink the libraries
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/
Install PIL
$ pip install PIL
Setup folders
$ cd /web
$ sudo mkdir [project_name]
$ cd [project_name]
$ sudo mkdir source logs www
Create a new SSH key for GitHub
$ sudo ssh-keygen -t rsa -C "[email protected]"
- Note: You should generate a new key as root.
Add content from $HOME/.ssh/id_rsa.pub to GitHub and clone the project
$ [email protected]:[github_username]/[repo_name].git