Skip to content

Instantly share code, notes, and snippets.

@yareally
Created September 23, 2013 10:38
Show Gist options
  • Save yareally/6668832 to your computer and use it in GitHub Desktop.
Save yareally/6668832 to your computer and use it in GitHub Desktop.
Setting up Redis + Flask + Tornado and some other packages to do comet/async related stuff Will be adding as I go
# note that some commands may require root (sudo) in front of them
# -- installing python, tornado, flask and related packages --
# install aptitude for better package management (it's just an apt-get wrapper)
apt-get install aptitude
# install pip to deal with python package installs/updates
aptitude install python-pip
# install virtualenv to create a self-contained python install separate from the OS
pip install virtualenv
# create a directory for virtualenvs (and a directory for python projects)
mkdir -p ~/python-projects/virtualenv
# go to the created directory
cd ~/python-projects/virtualenv
# create the virtual enviroment for the website
virtualenv twitter-clone
# set the created virtual enviroment as the active one
ln -s twitter-clone/bin/activate .
# add the virtual enviroment to the system path so you can tell it's active
source activate
# check to ensure the created virtual enviroment is added to the system path
echo $PATH
# add this file to somewhere to easily switch between virtualenvs (this will fetch it and save it to your home directory)
wget -O ~/venv_switch.sh https://gist.github.com/yareally/6668118/raw/7edfa0f6fc28a99995f24e97cf73bc61744bb1fc/venv_switch.sh
# set executable permissions on the file
chmod +x ~/venv_switch.sh
# add this file to link your base profile with the virtual enviroment
wget -O ~/.virtualenvrc https://gist.github.com/yareally/6668254/raw/920bb5fbf02b2cddeac7464853e59c28f230d332/.virtualenvrc
# switch between virtualenvs by doing the following (like on a reboot):
~/venv_switch.sh twitter-clone
# Now all package installs and the currently used python version will be the one in ~/python-projects/virtualenv/twitter-clone/
# you can ensure that it is (for sanity reasons) by typing the following (which will show the path to the current python interpreter):
which python
# ignore all warnings when setting up stuff below (they're normal)
# install tornado (http://www.tornadoweb.org/en/stable/) async web server to handle all server async stuff
pip install tornado
# install flask (http://flask.pocoo.org/) for doing MVC (as tornado will just run in flask as part of a controller and handle anything async, while flask does all the traditional web stuff)
pip install flask
# install a wrapper to deal with graph type object relations in redis (https://github.com/Doist/redis_graph) and (http://amix.dk/blog/post/19592#redis-graph-Graph-database-for-Python)
pip install redis_graph
# install tornado socketjs to help us easily deal with communication between client and server (https://github.com/mrjoes/sockjs-tornado). The client for it is here: https://github.com/sockjs/sockjs-client (directions for using with sockjs-tornado as well)
pip install sockjs-tornado
# -- getting redis --
# add dotdeb to your sources list
# open the file located at (/etc/apt/sources.list) with root/sudo
# add the following to the bottom of it:
deb http://packages.dotdeb.org wheezy all
deb-src http://packages.dotdeb.org wheezy all
# run the following to get the repostory verification keys for the above repos:
wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | sudo apt-key add -
# run update to be able to fetch from dotdeb
aptitude update
# install redis as the database server
aptitude install redis-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment