Dave Perrett

Subversion Server on CentOS

linux, programming, subversion, version control, web

  1. Install a couple of packages via yum :
1
$ sudo yum install httpd subversion mod_dav_svn
  1. Create a directory to store the svn repositories in :
1
2
$ sudo mkdir -p /var/lib/subversion/repositories
$ sudo chown -R apache:apache /var/lib/subversion
  1. Because I make and delete repositories quite a lot, i made a script to build them. Save this script somewhere and make it executable. I saved it as /bin/make-repos so i can use it from anywhere.
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/sh

if [ $# -ne 1 ]; then
    echo 1>&2 Usage: $0 repository_name
    exit 127
fi

echo "Sudoing...";
sudo svnadmin create --fs-type fsfs /var/lib/subversion/repositories/${1}
sudo chown -R apache:apache /var/lib/subversion/repositories/${1}
sudo chmod -R g+w /var/lib/subversion/repositories/${1}
sudo chmod g+s /var/lib/subversion/repositories/${1}/db
  1. Create a new file /etc/httpd/conf.d/svn.conf with the following contents :
1
2
3
4
5
6
7
8
9
10
11
12
13
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

<Location /svn>
  DAV svn
  SVNParentPath /var/lib/subversion/repositories
  SVNListParentPath on
  SVNPathAuthz off
  AuthType Basic
  AuthName "[email protected]"
  AuthUserFile /var/lib/subversion/passwords
  Require valid-user
</Location>

You may not need the first 2 LoadModule lines if they are already in your global httpd.conf.

  1. Create your password file:
1
$ sudo htpasswd -c /var/lib/subversion/passwords new-user-name

Where new-user-name is the name of the user you want to create.

  1. Restart Apache and you’re done!
1
$ sudo /etc/init.d/httpd restart

If you create a couple of repositories with your make-repos script and browse to http://your.server.domain/svn you should see a browsable list of the repositories you’ve created.