-
Notifications
You must be signed in to change notification settings - Fork 0
Install guide
These instructions will guide you through the process of setting up a reddit clone for the first time. We also have an automated install script for Ubuntu Linux.
Before continuing with this guide, make sure you have all of reddit's many dependencies installed. See one of the following guides for details.
This guide will assume that you are installing reddit as user reddit in the directory /home/reddit. If this is not the case, modify the examples accordingly.
Clone the git repository available here on github.
$ git clone git://github.com/reddit/reddit.gitOnce this is done, you'll need to install the python module dependencies.
$ cd reddit/r2
$ sudo python setup.py develop
$ makeThe setup.py script only needs to be run at installation time, but the Makefile will need to be rerun any time you modify a Cython file (*.pyx) so that the code can be compiled.
PostgreSQL is reddit's primary data store. It is used for storing data on Accounts, Subreddits, Links, Comments, Votes, etc. In production, we use many separate database clusters, but for sites with less traffic (or test instances) a single postgres database should suffice.
This section may be unnecessary on your system. Check if your installation of postgres created a default database and start scripts for you.
If one doesn't already exist, create an account for postgres to run under. This guide will assume the name postgres.
$ adduser postgresCreate a directory for postgres to store its data in.
$ sudo mkdir -p /usr/local/pgsql/data
$ sudo chown postgres /usr/local/pgsql/dataThen, initialize the database.
$ sudo -u postgres initdb -D /usr/local/pgsql/dataFinally, start up the server.
$ sudo -u postgres postgres -D /usr/local/pgsql/dataCreate a database for reddit's data.
$ createdb -E utf8 redditThen add reddit's SQL functions to the schema.
$ cd ~/reddit/
$ psql -U reddit reddit < sql/functions.sqlFor testing purposes, you can generate random test data for your reddit install.
$ cd ~/reddit/r2
$ paster shell example.ini>>> from r2.models import populatedb
>>> populatedb.populate()Note: this will also create a user named reddit with password password.
Cassandra is currently used primarily as a permanent cache, but the goal is for it to become our primary data store. As such, it is a vital component the reddit architecture.
To configure Cassandra for reddit, set up the necessary directories and replace the default storage.yaml with the one that comes with reddit.
# the /cassandra directory is configured in reddit's cassandra.yaml. you may change it if desired.
$ sudo mkdir /cassandra
# make sure the cassandra directory is accessible to the user cassandra will run as.
$ sudo chown cassandra /cassandra
# the path to cassandra.yaml may vary depending on your system. change as necessary.
$ sudo mv /etc/cassandra/cassandra.yaml /etc/cassandra/cassandra.yaml.bak
$ sudo ln -s ~/reddit/config/cassandra/cassandra.yaml /etc/cassandra/Next, you need to create the keyspace for reddit and the permacache column family.
$ cassandra-cli
[default@unknown] connect localhost/9160;
[default@unknown] create keyspace reddit with replication_factor = 1;
[default@unknown] use reddit;
[default@unknown] create column family permacache with column_type = 'Standard' and comparator = 'BytesType';
The reddit application will create the rest of the required column families automatically.