Friday, November 11, 2011

How to install Trac on a Synology DS2011+

In a previous post, I described installing Trac on a Synology DS209+II. I recently had to migrate this installation to a Synology DS2011+ and ran into some snags. This post will help you avoid spending all the hours I did on getting it to work.

Modifying the Synology DiskStation

To be able to do anything to your DS2011+, you first have to install the ipkg bootstrap. I basically followed along with page on the synology forum Overview on modifying the Synology Server, bootstrap, ipkg etc.:

  • You need to enable ssh access to your NAS and then log in with PuTTY
  • The Synology DS2011+ has a "Marvell Kirkwood mv6282" processor, so these steps should do the trick:
cd /volume1/@tmp
wget http://wizjos.endofinternet.net/synology/archief/syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh
chmod +x syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh
sh syno-mvk-bootstrap_1.2-7_arm-ds111.xsh
rm syno-mvk-bootstrap_1.2-7_arm-ds111.xsh

After rebooting the NAS, you can enter these commands:

ipkg update
ipkg upgrade

We are now ready to start installing all the stuff needed for running Trac!

Software to install

Apache

Log on to your DS2011+ and install the following package:

ipkg install apache

Now we have a second httpd listening on port 8000. The configuration file for this instance of apache is /opt/etc/apache2/httpd.conf. You can find the log files in /opt/var/apache2/log. Also note that it is started on system boot by the script /opt/etc/init.d/S80apache. I suggest you execute this script and see if apache starts up nicely.

I ran into some problems with this installation: A syntax error on line 74 of /opt/etc/apache2/httpd.conf. Somehow apache can't load the mod_ext_filter.so. I didn't really care and just commented out that line.

Subversion

Create a new share using the DSM (that web interface on port 5000) - call it "svn". It will show up on your box as /volume1/svn.

I mainly followed the Step-by-step guide to installing Subversion on the Synology wiki. But I didn't bother messing with inetd.conf, since I am running svn under apache with mod_dav_svn. So, that leaves the following steps:

ipkg install svn
su svnowner
cd /volume1/svn
svnadmin create testsvn

You now have a new repository on your NAS called "testsvn". You just can't access it yet - but we'll fix that next! Also note that the Step-by-step guide to installing Subversion includes a few hints on how to get su svnowner to work if you get an error message.

To get Apache to serve your subversion repository, append this to /opt/etc/apache2/httpd.conf:

# Subversion
Include etc/apache2/conf.d/mod_dav_svn.conf

You will have to create /opt/etc/apache2/conf.d/mod_dav_svn.conf of course:

LoadModule dav_svn_module     libexec/mod_dav_svn.so
LoadModule authz_svn_module   libexec/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /volume1/svn
   AuthType Basic
   AuthName "Subversion repository"
   AuthUserFile /volume1/svn/svn-auth-file
   Require valid-user
</Location>

This expects a file /volume1/svn/svn-auth-file to be present. That file contains the passwords used for Subversion (and, via Apache, Trac authentication). This file is generated with apaches htpasswd -c command. I used the cm too, to force md5 hashing of the passwords.

Trac

So far, this guide is much the same as the one it replaces. The new stuff is in the version of python used:

ipkg install python26 py26-trac py26-genshi py26-setuptools sqlite svn-py

The need for upgrading comes from the package svn-py, which is now python 2.6.

Create a share (using the DSM) called "trac-env". This is where we will keep our trac installations.

I am now running Trac version 0.12. The Trac environments can be found at /volume1/trac-env. They are called "MYTRAC1" and "MYTRAC2". Access to them is via the following URLs:

Trac is run using tracd. This is configured to start automatically on system start by creation of the following file: /opt/etc/init.d/S81trac:

#!/bin/sh
# run tracd
/opt/bin/tracd -d -p 8888 -e /volume1/trac-env

The file must be set to executable for root (see documentation for chmod), so that it will be run at system start.

Trac configuration files can be found at

  • /volume1/trac-env/MYTRAC1/conf/trac.ini
  • /volume1/trac-env/MYTRAC2/conf/trac.ini

Authentication via Apache

appended following lines to /opt/etc/apache2/httpd.conf:

# Subversion
Include etc/apache2/conf.d/trac.conf

And then, create the file /opt/etc/apache2/conf.d/trac.conf:

# allow Apache to be used for authenticating Trac
<Directory /opt/share/www/trac>
   AuthType Basic
   AuthName "Subversion repository"
   AuthUserFile /volume1/svn/svn-auth-file
   Require valid-user
</Directory>

Authentication is done with the AccountManager plugin for trac (http://trac-hacks.org/wiki/AccountManagerPlugin). The website has a good explanation on how that works. See the copies of the trac.ini files for reference. I'd like to point out the last section:

[account-manager]
password_store = HttpAuthStore
authentication_url = http://myserver.example.com:8000/trac

This is where we tell Trac to use our Apache Server for authentication. Note how the authentication_url is the same as the Directory in trac.conf.

Backup

Backup is still the same as in the previous post, so I'll just point you there: http://darenatwork.blogspot.com/2011/03/how-to-install-trac-on-synology-ds209ii.html