Quick SVN & Trac Installation on CentOS/Fedora

Tested on CentOS 4 but the assumption is that this same setup should work on both Fedora and Redhat. SELinux has been disabled for this setup.

Install the mod_dav_svn module:
#yum -y install subversion mod_dav_svn

CREATE SUBVERSION ROOT REPOSITORY


#mkdir /srv/svn
#svnadmin create /srv/svn/repos
#chown -R apache /srv/svn/repos

ENABLING SVN HTTP ACCESS USING APACHE WEBSERVER

1.) Backup the original subversion.conf file that might be on your system.
#mv /etc/httpd/conf.d/subversion.conf /etc/httpd/conf.d/subversion.conf.old
#vi /etc/httpd/conf.d/subversion.conf

2.) After opening your subversion.conf file above, insert the following directives:

<Location /svn>
DAV svn
SVNParentPath /srv/svn
#SVNListParentPath on
# authentication
AuthType Basic
AuthName “Repository Name”
AuthUserFile /srv/users
Order deny,allow
Require valid-user

# authorization
# AuthzSVNAccessFile “/etc/httpd/conf/svn-auth.ini”
</Location>

Add a new user who can be authenticated against the repository:
#htpasswd -cm users user1

The first user you add, will require you to use the -cm switch. From then on, create new users as shown below:
#htpasswd -m users user2

SVNListParentPath allows you to have several repos under the same svn directory ie you can create repo2 and repo3…repon under the svn directory and apache will still be able to serve them.

PLEASE ENSURE YOU DO NOT PLACE the /srv/users file under the /srv/svn directory. This is because should you decide to list the files under this directory, and you allow anonymous access to this directory on apache, all your visitors to /srv/svn will be able to see your password.

Other authentication types include LDAP and Basic authentication. References:

> http://httpd.apache.org/docs/2.0/howto/auth.html (Basic authentication)
> http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html (LDAP)

Using LDAP has the benefit of having a universal authentication, authorizaton and access for your system configured from one place. Thus, LDAP system users, would automatically be users on the Subversion Server (as well as the Trac Server).

IMPORT PROJECTS INTO SUBVERSION REPOS

#svn import -m "Initial Import" local-directory-projectX http://server-name/svn/projectX

INSTALLING TRAC SERVER ON CENTOS

Enable extra repositories on Centos (Fedora and Redhat should be able to use the dag repository. Not sure about the karan repository):

#cd /etc/yum.repos.d
#vi dag.repo

Paste the following:

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1


#wget http://centos.karan.org/kbsingh-CentOS-Extras.repo
#wget http://centos.karan.org/kbsingh-CentOS-Misc.repo

#rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
#rpm --import http://centos.karan.org/RPM-GPG-KEY-karan.org.txt

#yum install mod_dav_svn mod_python clearsilver python-clearsilver python-sqlite trac

CONFIGURE TRAC SERVER ON APACHE WEBSERVER

#trac-admin /srv/trac initenv

Your repository path would be /srv/svn/repos when asked by trac-admin. Choose your desired Project Name. All other default values should be ok to use.

#chown apache:apache /srv/trac

Create a trac.conf file:

#vi /etc/httpd/conf.d/trac.conf

And paste the following

<Location /trac>
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /srv/trac
PythonOption TracUriRoot /trac

# authentication
AuthType Basic
AuthName “JoeWami Trac Server”
AuthUserFile /srv/users
Require valid-user
</Location>

Notice we use the same authentication file as above (Please see subversion.conf)

Finally, ensure you are loading the following modules for apache dav svn to work:

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

GOTCHAS

1.) Watch out for mod_security/mod_security2, either turn it off or enable mod_security(2) to let through dav requests (/etc/httpd/conf.d/mod_security.conf)

6 Comments »

  1. freakQNC said

    Errata:
    The line #svnadmin create –fs-type fsfs /srv/svn/repos
    should read #svnadmin create –fs-type fsfs /srv/svn/repos

  2. freakQNC said

    Just saw my post and I belive wordpress is getting in the way the as it turns a double minus sign into an m-dash character.

    so the line to correct is: #svnadmin create [type two consecutive minus characters here]fs-type fsfs /srv/svn/repos

    I have to use the explanation in square brackets as writing “–” would not show the 2 minus characters… but one “m-dash” sign.

  3. jwamicha said

    I’ve tried everything getting fs-type to display correctly but wordpress just doesn’t allow the double minus characters. I eventually removed this option since by default svnadmin will use “fsfs” which is enough for most users.

    Thanks freakQNC.

  4. […] If you have not done so already, begin by installing Subversion on your system. For Fedora/CentOS/Redhat users, this is explained in another post here: https://jwamicha.wordpress.com/2008/04/25/quick-svn-trac-installation-on-centosfedora/ […]

  5. Hossain said

    For some reason when i browse to /trac i get following apache error


    [error] [client 192.168.0.103] PythonHandler trac.web.modpython_frontend: IOError: [Errno 2] No such file or directory: '/srv/trac/VERSION'

    Resulting Internal Server Error
    Any idea why this might happen ?

  6. Hossain said

    OKey, I found the problem….. I was using multiple repos for SVN+TRAC

    so instead of

    PythonOption TracEnv /srv/trac

    you should use:

    PythonOption TracEnvParentDir /srv/tracrepos

RSS feed for comments on this post · TrackBack URI

Leave a comment