Trac, SVN quick howto on a linux Debian

In the following, I will present a mini guide to setup Trac 0.10.3 and SVN services on a Linux Debian stable.

I needed a per project authentication both in trac and in svn.

I just finished it, seems to be working, will check it out in a few days, hope it does not burn your PC🙂 and that I did not forget anything crucial.
Careful when copy pasting code, the double quotes get messed up.

TRAC Installation

% apt-get install trac
% apt-get install libapache2-mod-python2.4
% sudo mkdir /var/lib/trac
% sudo chown www-data:www-data /var/lib/trac

In apache ( for example in /etc/apache2/sites-available/default ) <-you should create a separate file for trac.

ACCESS TRAC through apache

<Location /projects> #set up Trac handling
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/lib/trac
PythonOption TracUriRoot /projects
</Location>

SVN

% sudo apt-get install libapache2-svn subversion #not sure if anything else is needed
% sudo mkdir /var/lib/svn
% sudo mkdir /var/lib/svn/MyProject
% sudo svnadmin create /var/lib/svn/MyProject
% sudo svn mkdir file:///var/lib/svn/MyProject/branches file:///var/lib/svn/MyProject/tags file:///var/lib/svn/MyProject/trunk -m "initial structure"
% sudo chown -R www-data /var/lib/svn/MyProject
% sudo chown -R www-data /usr/share/trac
% sudo apache2 -k restart

TRAC – Create a new Project/add apache authentication to it

% sudo trac-admin /var/lib/trac/MyProject initenv
#The previous command asks some basic questions,leave them as they are, they should work except svn repository is located at /var/lib/svn/MyProject
% sudo chown -R www-data:www-data /var/lib/trac/MyProject

% htpasswd -c /var/lib/trac/MyProject/.htpasswd admin
enter new password:

The following goes to /etc/apache2/sites-available/default to order apache to use .htpasswd

<Location /projects/MyProject>
AuthType Basic
AuthName "MyProject"
AuthUserFile /var/lib/trac/MyProject/.htpasswd
Require valid-user
</Location>

SVN Access via Apache in /etc/apache2/sites-available/default
Add Authentication for MyProject SVN access


<Location /svn>
DAV svn
SVNListParentPath on
SVNParentPath /var/lib/svn/
</Location>
<Location /svn/
MyProject>
AuthType Basic
AuthName "MyProject Subversion repositories"
AuthUserFile /var/lib/trac/MyProject/.htpasswd
Require valid-user
</Location>

Restart apache and cross your fingers.

The trac server should be available in http://foor.bar/projects/
It should have one project named MyProject.

The SVN server should be available through webdav (TortoiseCVS works) through the URL http://foo.bar/svn
It should have one project named MyProject.

Both should eb authenticated using admin and the password you specified.

:wq

5 Responses

  1. For each project that is created under Trac, a “login” page exists, which can distinguish, in a first level, the visitors of the project (based on the anonymous user permissions set) and the users of the same project. This can be setup in Apache configuration once for all Trac projects as follows:


    # Windows-based installation
    <LocationMatch /trac/[^/]+/login>
    AuthType Basic
    AuthName "trac"
    AuthUserFile f:/trac/trac.htpasswd
    Require valid-user
    </LocationMatch>

    Now, if you want to access Trac and/or SVN via a public network, it is wise to setup a https port in Apache. Suppose you a have a valid ssl configuration in Apache, add the following in the <IfDefine SSL> section:
    <Location />
    Deny from all
    </Location>

    <Location /trac>
    Allow from all
    </Location>


    <Location /svn>
    Allow from all
    </Location>

    The above setup will limit the public access only to /trac and /svn locations via https. Consider to setup the firewall to allow incoming connections only to https port (443 by default) or this setup will have no meaning. Moreover, you can have more elaborate ip access control using the allow, deny keywords than the basic setup presented here.

  2. @Jannis: I just browsed through the list of Trac plugins in http://trac.edgewall.org/wiki/TracPlugins and I did not find anything very interesting with possibly the exception of “Web Admin Plugin”. Would you suggest a particular one?

  3. @Stavros plugins depend on what functionality you need on the Trac wiki; webadmin probably is the most useful (I believe it’s incorporated in newer Trac versions).

    I use tBlog; creates blog-like wiki posts and TracTags, for tagging wiki pages. Both great if you want to make rough notes or diary-like entries for your projects. Less useful if you’re only interested in the repository browser, timeline and tickets for your code.

  4. @Stavros sorry for the late answer. Most of the plugins developed for Trac are located in http://trac-hacks.org/wiki/WikiStart. A short list of plugins is maintained also in http://trac.edgewall.org/wiki/PluginList.
    I agree with the plugin list nsaunders wrote. I would add PageToPDF also.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: