Installing Reddit on Ubuntu 10.10
Getting started:
OK, so I’m going to assume you have a stock installation of Ubuntu 10.10. Like, fresh out of the ISO, and that all you’ve done is create the default user account.
I’m also assuming this isn’t going to be a production install. (So I’m going to skip some of the things like isolating services & users, setting up firewall rules, SSH, log cleanup, etc).
These instructions were working with the Reddit codebase as of November 10th, 2010.
Dependencies:
The Reddit codebase hasn’t met a dependency it didn’t like. So, first things first you’re going to need to install a few packages:
sudo apt-get -y install curl sudo apt-get -y install git sudo apt-get -y install subversion sudo apt-get -y install python-dev sudo apt-get -y install memcached sudo apt-get -y install libmemcached-dev sudo apt-get -y install postgresql sudo apt-get -y install libpq-dev sudo apt-get -y install libxslt-dev sudo apt-get -y install rabbitmq-server sudo apt-get -y install openjdk-6-jdk sudo apt-get -y install python-setuptools
Configuring PostgreSQL:
sudo -u postgres createdb -E utf8 reddit sudo -u postgres createuser -P reddit
You’ll need to type ‘password’ twice here, then ‘y’.
Configuring RabbitMQ:
sudo rabbitmqctl add_user reddit reddit sudo rabbitmqctl set_permissions -p / reddit ".*" ".*" ".*"
Configuring the correct version of WebHelpers:
Note: I’m pretty sure it has to be the 0.6.4 version of WebHelpers, and not the latest package.
cd /tmp curl -O http://pypi.python.org/packages/source/W/WebHelpers/WebHelpers-0.6.4.tar.gz tar zxvf WebHelpers-0.6.4.tar.gz cd WebHelpers-0.6.4 sudo python setup.py install
Installing & configuring Cassandra:
cd ~ mkdir cassandra cd cassandra curl -O http://mirrors.axint.net/apache//cassandra/0.6.6/apache-cassandra-0.6.6-bin.tar.gz tar zxvf apache-cassandra-0.6.6-bin.tar.gz
You’ll need to edit ~/cassandra/apache-cassandra-0.6.6/conf/storage-conf.xml. You can’t just copy over the config provided in the Reddit repo if you’re using a more recent version of Cassandra. Specifically, you’ll need to:
- Change ClusterName to redditdev
- Change AutoBootstrap to true
- Copy the contents of the “Keyspaces” section from ~/reddit/config/cassandra/storage-conf.xml into the “Keyspaces” section of this file
Finally, you need to start Cassandra. I’ve been doing this as root, again, not a good practice in production.
sudo ~/cassandra/apache-cassandra-0.6.6/bin/cassandra
Installing Reddit:
cd ~ git clone http://github.com/reddit/reddit.git sudo -u postgres psql reddit < ~/reddit/sql/functions.sql cd reddit python setup.py develop make
You’ll need to edit ~/reddit/r2/example.ini. Specifically you’ll need to:
- Change write_query_cache to false
- Add INDEXTANK_API_URL = localhost to the end of the file
Startup:
cd ~/reddit/r2 paster serve --reload example.ini http_port=8080
Cleanup:
Cassandra should be set up to start at startup. Installing a rc.d script is left as an exercise to the reader.
Notes:
2010/11/30 - Fixed quick glitch in Cassandra install instructions
2010/11/14 - Cleaned up in move from Tumblr, added timestamp on intro. Need to do a better job picking branches, getting Cassandra setup.
2010/11/11 - Fixed issue with task sequence, streamlined sudos.
2010/11/10 - Initial version.