Subversion Server on Mac OS X Leopard Server

Filed under Apple + Mac OS X Server on Sunday, 7 March, 2010 12:13 pm

Subversion and Mac OS X Server image

Nayan Hajratwala over at Agile Shrugged managed to write a really great article describing how he got Subversion repos running on Mac OS X Server.

I got mine working on Mac OS X 10.5.8 but had to make a few different changes in order to get things working. His doesn't deal with multiple SVN repositories, only with a single one. This isn't ideal and I highly doubt anyone would go to the trouble of installing a SVN server and only ever need ONE svn repository.

I would suggest using /opt/repos/svn as the master path as the Open.collab.net developers recommend doing it this way on Mac OS X.

I'd be interested to know if you could make that an alias to an external drive with svn being a symbolic link inside the /opt/repos folder, which points to a location on an external volume like: /Volumes/External HD/svn. I will try this some day but if anyone knows if this actually works, please leave a comment.

Step 1 - Create a root SVN folder

Open Terminal.app:

sudo mkdir -p /opt/repos/svn

Step 2 - Create your SVN repository

sudo svnadmin create /opt/repos/svn/test
sudo chown -R www:www /opt/repos/svn

The second line makes Apache own this path and everything inside it including your new repo.

Step 3 – Configure the Apache web server via Server Admin

Server Admin is located in /Applications/Server/Server Admin.

1. Click Web in the Sidebar

2. Click Settings in the top bar

3. Select the Modules tab

4. Check the following modules:

authz_svn_module
dav_module
dav_fs_module
dav_svn_module

Step 4 – Enable WebDAV on your site

Reading comments, it seems that some people don't think you need this step. However for my configuration I'm pretty sure you do need to do this.

1. Click Sites in the top bar

2. Select your site

3. Click the WebDAV checkbox

Step 5 - Create a Realm

This will set up the OpenDirectory based security. We will be using Basic authentication only.

1. Select the Realms tab

2. Click “+” under the Realms box and enter the following:

    Realm Name: svn_realm
    Authentication: Basic
    Location: /svn (Note: You have to change the dropdown to 'Location', not 'Folder').

3. Click “+” under the Users & Groups box, and drag/drop the users/groups that you want to give access to. Also be sure to give them read/write privileges...then press the Save button.

Step 6 – Tweak the Apache config file

There is no graphical UI to do this. So you need to use Terminal.app.

Edit the file under /etc/apache2/sites that corresponds to your site.

This should be a file starting with 000x.

In the <location "/svn"> section, add the following three lines:

DAV svn
SVNParentPath /opt/repos/svn
SVNListParentPath On

This is what mine looks like:

Step 7 – Restart the web server

You can do this from Server Admin ('Stop Web', then 'Start Web').

You should be able to access your repository at http://myserver/svn or locally at: http://localhost/svn

Be careful not to change any other settings in the Web portion of Server admin.

If you do it will change DAV svn to DAV Off again.

Free free to leave any comments and suggestions :)

6 Comments »

Comment by Paul Zain

May 11, 2010 @ 1:59pm

Thanks! You rock!

Comment by Brock Woolf

May 11, 2010 @ 5:04pm

Glad I could help you out Paul ;)

Comment by Jeremy A

May 15, 2010 @ 2:01pm

Hey! I tried a guide I found over at the Apple dev site article here and I couldn't get this to work. So then I googled around and found your site. I've set this up on an SSL-enabled site. For some reason, whenever I try to access the site and log in, I get a 500 error. Log says "Could not open the password file: (null)". Looks to me like apache isn't seeing whatever password file the server should be using. Now when I've worked with apache before I've used the AuthUserFile to specify a htpasswd file. The site config file that Server Admin is creating doesn't seem to do that. I've got OpenDirectory enabled of course and I've created a couple users and groups on the server, in the LDAPv3 directory. Suggestions are welcome.

Comment by Brock Woolf

May 18, 2010 @ 3:58pm

@ Jeremy:

I wasn't using SSL, LDAP or OpenDirectory. I've not seen that error and it probably has something to do with SSL,etc.
I would start at ground zero, disable those other fancy protocol and services, then follow the guide precisely.

"Could not open the password file (null)" sounds like a permission problem to me. Make sure Apache owns the password file.

Comment by Dallas Hockley

June 2, 2010 @ 12:39pm

Great step-by-step. Worked flawlessly the first time. Many thanks for sharing the knowledge!

Comment by Brock Woolf

June 2, 2010 @ 1:17pm

@Dallas Hockley
Glad to hear it worked for you :)

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

8) :wink: :P :D :) :o :? :( :x