Installing a Subversion (SVN) server on Mac OS X

I use my Mac OS X laptop (a MacBook Pro) almost exclusively these days, often working in a library or coffee shop, but I still want the power of a version control system with me. I finally decided to install a Subversion (SVN) server on my MacBook, and it was surprisingly easy. (I say “surprisingly” because the few links I’ve found online led me to believe it would be much harder to install SVN on Mac OS X.)

Rather than write a full-blown SVN installation tutorial or SVN installation manual, I’m just going to put my notes out here. Hopefully they’ll be sufficient to help you get Subversion/SVN installed on your Mac as well.

  1. Open a Terminal, and run
    fink install svn

    . (The SVN package is the SVN server.) Supply the password when prompted.

  2. This installs
    svnserve

    , and nine other supporting packages. There’s more fink svn information here

  3. That’s all you need to do to get the server installed on your system. You still have to configure it and start it up, but before doing that I downloaded the SVN command line client.
  4. Type
    fink install svn-client

    to install the SVN client.

  5. Type
    fink install svn-doc

    to install the documentation.

  6. I want to create a repository out of my home directory (to make it easier for backups), so I created it like this:
    svnadmin create /Users/al/svnrepo
  7. I edited the
    conf/svnserve.conf

    file to change a few lines. If you want to use SVN without user accounts this isn’t 100% needed, but I do want to have my name on all those check-ins, so I made a few changes. See the “svnserve.conf configuration file” section later on this page for details.

  8. I also edited the
    conf/passwd

    file at this time. This is also discussed below.

  9. Technically I started
    svnserve

    at this time, but quickly ran into a permission problem on my first check-in. Reading the docs it looks like the repo needs to be owned by the “www” user (as that’s the owner of the

    svnserve

    process), so I ran this command from the directory just above my repo:

    find svnrepo -exec chown www.www {} \;

    . That gave me a warning/deprecated message, but still changed all the repo files to be owned by the “www” owner and group. (Break this into two separate commands if you need to.)

  10. I started the SVN server like this:
    sudo -u www /sw/bin/svnserve -d -r /Users/al/svnrepo
  11. I haven’t looked back since. 😉

svnserve.conf configuration file

With Subversion you have a configuration file named

conf/svnserve.conf

. Here’s what my

conf/svnserve.conf

configuration file looks like, with my comments still included:

[general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are "write", "read",
### and "none".  The sample settings below are the defaults.
anon-access = read
auth-access = write

### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### Uncomment the line below to use the default password file.
password-db = passwd

### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
realm = Laptop Realm

Here’s what my

conf/passwd

file looks like:

[users]
al = al

So if you want to bust into the SVN server on my MacBook Pro that should make it pretty easy. 🙂

The end

That was all I had to do to install a Subversion server on my Mac. After this I started using normal SVN commands and everything worked as advertised.

As mentioned, from my research it sounded like it was going to be hard to get an SVN server running on my Mac, but I didn’t have any real problems, other than I’d never installed an SVN server before, so this was my first time. I’m sure I’ll learn more as I go on, but hopefully that will help you get started using SVN on your Mac as well.

Reference

Here’s a little more help … it’s the output from one of the commands I ran early on:

Type 'fink describe svn' to get usage help.

Type 'svnserve --help', 'man svnserve', 'svnadmin help', or 'man svnadmin'
for usage.
Some tools (e.g. hook and back-up scripts) and examples are stored in
/sw/share/svn/tools and /sw/share/svn/contrib
.
You can start the Subversion server manually using a command similar to
'/usr/bin/sudo -u www /sw/bin/svnserve -d -r /sw/var/svn' or you can
run 'daemonic enable svnserve' as root to create a StartupItem for it.
.
'svnserve' is run as user 'www' in order that apache and svnserve can
access the same repositories at the same time under '/sw/var/svn'
.
You could install the repositories under the preconfigured directory
/sw/var/svn
which should have the correct permissions. Make sure that all files
in the new repository have the correct permissions for svnserve (and apache)
to read and write. E.g. run 'chown -R www /sw/var/svn/yourrepos' and
'chmod -R go-rwx /sw/var/svn/yourrepos'.

I didn’t know you could run

chown

like that; learn something new every day. I didn’t run the

chmod

command, and haven’t had any problems, but I’ll do that next. It makes the ownership for “group” and “other” on all files to be “rwx”, or 777.

Leave a Reply

avatar
  Subscribe  
Notify of