Saturday, December 29, 2012

I recently installed RhodeCode onto Simpson's server. Awesome program, but setup isn't quite as easy as I'd like. So here are my notes, in case anyone else is interested.
I relied heavily on the following sites for information:
Installation was done on a Debian Wheezy system.
First, become superuser.
sudo bash
Install pre-requisites.
apt-get install python-all-dev python-pip python-mysqldb rabbitmq-server python-virtualenv libmysqlclient-dev
easy_install -U distribute
pip install mysql-python
pip install virtualenv
Set up the message queue system.
rabbitmqctl add_user rhodeuser mypassword
rabbitmqctl add_vhost rhodevhost
rabbitmqctl set_permissions -p rhodevhost rhodeuser ".*" ".*" ".*"
I prefer mysql for the database. Set this up.
mysql -u root -p

create database rhodecode character set utf8; 
create user 'rhodecode'@'localhost' identified by 'mypassword';
grant all privileges on rhodecode.* to 'rhodecode'@'localhost';
flush privileges; 
Create a directory for installation
cd /var
mkdir rhode
chown www-data rhode
cd rhode

virtualenv --no-site-packages /var/rhode/venv
cd /var/rhode/venv/bin
source activate

cd /
pip install pastescript
pip install rhodecode

cd /var/rhode/venv/bin/
tar -zxf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
python build
cd ..

paster make-config RhodeCode production.ini
Edit production.ini so it looks like this:
vim production.ini
# -----
use_celery = true
# = localhost
broker.vhost = rhodevhost
broker.port = 5672
broker.user = rhodeuser
broker.password = mypassword

# Find this line and change to:
sqlalchemy.db1.url = mysql://rhodecode:mypassword@localhost/rhodecode
paster setup-rhodecode production.ini --user=rhodeuser --password=mypassword --repos=/mnt/hg_repos
/etc/init.d/rabbitmq-server start
See if celery works and hooks up to the message queue. If it does, hit ctrl-c and go to the next step. If it doesn't, debug before continuing.
paster celeryd production.ini
Start running. Then see if it works.
paster celeryd production.ini &
paster serve production.ini
I really wanted to use wsgi to serve stuff up. But I couldn't get authentication working. I am sad.
vim apache.conf
    WSGIScriptAlias /repo /var/rhode/venv/dispatch.wsgi
    WSGIPassAuthorization On
    WSGIDaemonProcess rhodecode user=www-data group=www-data threads=1 processes=10
    WSGIDaemonProcess pylons \
        threads=4 \

More wsgi stuff I didn't get working.
vim /var/rhode/venv/dispatch.wsgi
import os
os.environ["HGENCODING"] = "UTF-8"
os.environ['PYTHON_EGG_CACHE'] = '/var/rhode/venv/.egg-cache'


import site

from paste.deploy import loadapp
from paste.script.util.logging_config import fileConfig

application = loadapp('config:/var/rhode/venv/bin/production.ini')

To get the pass-through proxy working, this is what I did. First, enable the proxy mods:
a2enmod proxy_http
a2enmod proxy
a2enmod mod_headers
And some other stuff. I'll finish my notes later.