Subversion Server on CentOS

1. Install a couple of packages via yum:

$ sudo yum install httpd subversion mod_dav_svn

2. Create a directory to store the svn repositories in :

$ sudo mkdir -p /var/lib/subversion/repositories
$ sudo chown -R apache:apache /var/lib/subversion

3. 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.

#!/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

4. Create a new file /etc/httpd/conf.d/svn.conf with the following contents :

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 "subversion@tokyo"
  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.

5. Create your password file:

$ sudo htpasswd -c /var/lib/subversion/passwords new-user-name

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

6. Restart Apache and you’re done!

$ 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.



9 Responses to “Subversion Server on CentOS”  

  1. 1 Jason Sjöbeck

    Thanks for this page.

    I have done this & now I want to make our “git” accessible repository & our “svn” repository share the same set of folders, or the same set of repositories, but be accessible by either protocol at the same time. I will start googling on how to do this, if possible, next. If any one else is interested in this, or has done this, or has any tips/pitfalls/warnings/etc/etc/etc please post them here.

    The idea is to have one repository accessible by our older servers & our newer servers at the same time, as well as our engineers from their laptops any where in the world at any time. This would be fantastic.

    We can then put some hooks in to some of our sites & servers & others to auto check-in the last configuration when ever a configuration is updated.

  2. 2 Yugandhar Kumar M

    Thanks for this page.

    I follow up this page for installing SVN server on centOS. I installed properly, but i didn’t understand the following things:

    1. I’m unable to create multiple user. It’s over writing the passwords file for every time I’m creating a new user.
    2. I can able to connect from we browser, but not with tortoise SVN why this is happening?

  3. 3 dave

    @Jason: Let me know how you go with git integration. I’ve been thinking about trying to set up exactly the same thing – I’d love to hear how you go.

  4. 4 dave

    @Yugandhar Kumar

    1. Remove the ‘-c’ option to add new users – ‘-c’ tells it to create a new file.

    2. Tortoise SVN should be able to connect using http:// – what address are you trying to connect to? If you’re using svn:// you need to run svnserve as well.

  5. 5 Marton Sari

    Thank you very very much for this tutor. It helped me a lot. Everything worked flawlessly. Excellent article.

  6. 6 bolkin

    LoadModule dav_svn_module modules/mod_authz_svn.so
    should be:
    LoadModule authz_svn_module modules/mod_authz_svn.so

  7. 7 dave

    Thanks bolkin, fixed!

  1. 1 Instalacja servera subwersion w systemie linux centos | Daniel Cz?stki
  2. 2 JerzySeweryn » Installing Subversion Server on CentOS


Leave a Reply