Trac and Gitolite: System Setup
egj trac , gitolite , sysadmin
First we install some packages:
apt-get update apt-get install build-essential python-dev emacs git-core subversion rsync apache2 libapache2-mod-wsgi postgresql libpq-dev postfix
Gitolite
Next is Gitolite installation. This blog post by Phil Whelan, "Gitolite Installation Step by Step", helped me get it working; the following is just a distillation of Phil's very helpful post, which provides more contextual explanation of what's happening and some extra tips.
On your local machine, create an SSH keypair called "gitolite" and then `scp gitolite.pub` to the server's `/tmp/` directory. Then:
adduser --system --shell /bin/bash --gecos 'git version control' --group --disabled-password --home /home/git git chown git:git /tmp/gitolite.pub && mv /tmp/gitolite.pub ~git/ su - git mkdir bin cd /tmp && git clone git://github.com/sitaramc/gitolite.git && cd /tmp/gitolite/install -to /home/git/bin/ /home/git/bin/gitolite setup -pk /home/git/gitolite.pub
You should now have gitolite installed and working properly. To double check, from your local machine, run:
ssh-add /path/to/ssh_keys/gitolite cd /tmp && git clone git@hostname.com:gitolite-admin.git
If this prompts you for a password, something's wrong. :-/ Running `ssh -v git@hostname.com` is a good starting point for debugging.
Trac
I installed Trac in a virtualenv under a dedicated system user's homedir, with each Trac instance living in a subdirectory of `$HOME/sites/`.
adduser --system --shell /bin/bash --gecos 'trac project management' --group --disabled-password --home /home/trac trac su - trac git clone git://github.com/pypa/virtualenv.git mkdir bin ln -s /home/trac/virtualenv/virtualenv.py ./bin/ mkdir web ./bin/virtualenv.py web/ve echo "Trac" > web/requirements.txt web/ve/bin/pip install -r web/requirements.txt mkdir sites echo "import sys sys.stdout = sys.stderr import os os.environ['TRAC_ENV_PARENT_DIR'] = '/home/trac/sites' import trac.web.main application = trac.web.main.dispatch_request " > web/wsgi.py
I then set up an Apache virtual host to serve Trac with mod_wsgi at http://hostname.com like so:
a2enmod wsgi echo "<VirtualHost *:80> ServerName hostname.com WSGIDaemonProcess site-trac user=trac group=trac threads=5 python-path=/home/trac/web/ve/lib/python2.7/site-packages WSGIProcessGroup site-trac WSGIScriptAlias / /home/trac/web/wsgi.py </VirtualHost>" > /tmp/apache.conf mv /tmp/apache.conf /etc/apache2/sites-enabled/hostname.com service apache2 reload
If you visit http://hostname.com in a browser, it should display an "Available Projects" landing page with no projects listed.
Let's create a throwaway project (using sqlite, because it's quicker) to check that everything's working; just press enter a few times at the prompts:
su - trac ./web/ve/bin/trac-admin ./sites/test initenv ./web/ve/bin/trac-admin ./sites/test permission add anonymous TRAC_ADMIN
Now if you reload the http://hostname.com homepage in your browser, a "My Project" link should show up. Click it; Trac's homepage should appear, with no errors.
We'll keep the testing environment around for now, so that we can use it to test Git/Trac commit integration next.
Related Posts
- Installing and Integrating Trac and Gitolite — Dec. 5, 2012 by egj
- Trac and Gitolite: System Setup (this post) — Dec. 8, 2012 by egj
- Integrating Trac and Gitolite: Round One — Dec. 15, 2012 by egj
- Integrating Trac and Gitolite: Using Postgres — Dec. 22, 2012 by egj