Subversion on OS X Leopard Server

2008 January 3
by Nayan Hajratwala

I’ve found various links to Subversion setup on OS X Server, but most of them leverage a lot of manual file editing rather than using the built-in features of OS X Server. Additionally, they didn’t discuss integrating OS X OpenDirectory.

That said, here is how I got my subversion repository up and running with the built in Apache 2 and OpenDirectory.

Step 1 – Create a Subversion repository

Since Leopard already has Subversion (1.4.4 as of this post), no software installation is required.

svnadmin create /usr/local/svn_repository

We also need to ensure that the repository is editable by the webserver user.

chown -R www /usr/local/svn_repository

You can create additional directories based on your preferred strategy, but you don’t need to in order to complete this setup.

Step 2 – Configure the server via Server Admin

Enable Apache modules

  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

Enable WebDAV on your site

Upon reflection, you may be able to skip this step, but I haven’t gone back and undone my changes to try it again. In any case, it can’t hurt.

  1. Click Sites in the top bar
  2. Select your site
  3. Click the WebDAV checkbox

Create a Realm

This will set up the OpenDirectory based security. There are options for Kerberos and Digest as well, but I haven’t tried setting those up.

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

Click the Save button.

Step 3 – Tweak the config file

Note — I’m using virtual sites. I suppose it would be similar if you’re not.

I couldn’t find any “Apple-ish” way to do this, so this is the only bit you have to manually edit.

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 two lines:

DAV svn
SVNPath /usr/local/svn_repository

Step 4 – Restart the web server

You can do this from Server Admin.

That’s  it.  You should be able to access your repository at http://yourserver.com/svn – Please let me know if I’ve made any errors or omissions.

Enjoy!

  • SandraMillhouse
    Most Subversion setups out there aren't working for me. I'm not really sure why and I don't think I'm doing anything wrong. Can some OS X settings influence the Subversion setup?
    Sandra Millhouse @ Virtual servers UK
  • Daniel
    unbelievable... this saved me hours and works like a charm. Thanks very much!
  • Wow! I'm going to try this tonight when I get home-- incidentally, Apple has broken your link to Server Admin Tools -- it can now be found here: http://support.apple.com/downloads/Server_Admin... :D Thanks again for the tip!
  • *sigh* This is what I get for getting overly excited-- I glossed over the "Server" part of the title :/ Oh well, I'll keep looking.
  • Ann
    Hello, very good tutorial.
    Do you know SPMPT ? It's an additional package for MAMP which include Subversion server, Trac (edgewall), python and mod_python. It's works out of the box.
    website : http://sonique54.free.fr/spmpt/
  • @z - unfortunately, i haven't tried with with 10.6.2, so i can't vouch for if it will work or not. I would've *hoped* that it would be easier...
  • z
    Hi All,
    After I followed all the above steps (several times with various iterations) I still have problems! For some reason with my setup doesn't allow me to see the repo with a web browser and I don't get an authentication box either. The only way I get it close to working is giving browsing access to everyone in the realm.
    Frustrated!
    -z

    ps I'm running os x server 10.6.2
  • In addition to my script to fix the 'DAV Off' occurrences:

    http://www.makkintosshu.com/journal/fixdavsvn

    I've added a launchd job to monitor modified apache config files and run `fixDAVsvn` on them whenever they're modified (esp. by Server Admin):

    http://www.makkintosshu.com/journal/automating-...

    @Tarik: this is probably an easier and better solution than pulling some config files out to a "manually managed" location as you can still edit them with Server Admin.
  • Amy
    This was the big help for me. Other tutorials only mentioned the two *svn* modules, but it seems all four need to be enabled:

    # Check the following modules:

    * authz_svn_module
    * dav_module
    * dav_fs_module
    * dav_svn_module
  • Ben
    @Trevor

    Had the same problem with setting a subdomain. I used a combination of SVNParentPath and SVNListParentPath to fix it:

    DAV svn
    SVNParentPath /path/to/svn
    SVNListParentPath On

    Hope this helps
  • what would this look like if you wanted svn to run on a subdomain instead? svn.example.com

    i can't get mine working. i got the require valid users part working, but when i get in it just says:
    Access forbidden!
    You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
  • I worked around the "DAV Off" problem by using the OSX admin gui to create a server, and a corresponding .conf file in sites/ , but then taking manual control of that site, as follows:

    1) Use the OSX admin gui to create a new server, which creates a corresponding .conf file in sites/ folder

    2) Rename and copy the conf file to some other directory for example /etc/apache2/manually_managed.conf

    3) In /etc/apache2/sites/virtual_host_global.conf, there are two lines created for each server (Listen and NameVirtualHost); add these to the end of /etc/apache2/manually_managed.conf, after the last line (after )

    4) Delete the new server from the OSX admin gui

    5) Edit /etc/apache2/manually_managed.conf by hand to set:
    DAV Off -> DAV svn

    6) In the main httpd.conf, in /etc/apache2/, manually add an include:
    Include /etc/apache2/manually_managed.conf

    7) run
    apachectl configtest
    to make sure everything works.

    The new server doesn't get broken or overwritten by changes made with the OSX admin gui. The big drawback is that the server has to be a separate port than any servers managed by the OSX gui, otherwise there will be conflicts.
    -Tarik
  • Anyway, quite a good and short description to get the job done.

    @iRod:
    I also have my repositories on an external drive and it works fine.
    I guess, you have something misconfigured with your SVNPath or SVNParentPath. My tip: it points to a directory, within a repository in it.
    Hope you get it fixed. Maybe you find this article from Apple interesting: http://developer.apple.com/mac/articles/server/...

    ~ Markus
  • I just whipped up a bash script to fix 'DAV Off' occurrences after using Server Admin, maybe others would find it useful:

    http://www.makkintosshu.com/journal/fixdavsvn
  • iRod
    Good article!
    I'm having a problem tough...
    I've tried to set up the Subversion directory on another Volume of the Server.
    So my custom SVNPath is: "/Volumes/Pool/Data/Subversion".
    Configuring and starting apache works fine, but when I am trying to access the project trough Xcode / WebBrowser I get the a "file not found" error. ("The URL you have loaded has not been found on this server.")
    I've checked the permissions on the external drive and they're www:admin throughout the whole Subersion/ directory. Does anyone have an idea what could cause the problem?

    regards
  • Arturo
    Very nice article, and thank you dre, this article saved me a lot of time.
  • dre
    Nice article :)

    As a convenience for other readers, follow the instructions in this blog post to the letter, and then do the following:

    1) Turn off the WevDAV option in Server Admin for the site.
    2) Using a text editor, open the site's config file in /etc/apache2/sites (e.g. 0000_any_80_.conf). Find the Location block for your svn repo. Change DAV Off to DAV svn, save changes, close the editor.
    3) sudo apachectl configtest (check for config file errors). If no errors...
    4) sudo apachectl graceful (reload config files)

    Remember that if you use Server Admin to modify the site's settings, the DAV svn entry may be overwritten / rewritten to DAV Off, so... don't do that ;)

    -dre
  • Tom
    This worked for me as well. I have a subdomain "svn.domain.tld" with several repositories mapped to /Repo1, /Repo2, /Repo3 etc...
  • Jim
    Thanks for this tip. It's saved me hours of work.

    I believe the step "Enable WebDAV on your site" is unnecessary and may cause problems. In my configuration, Apache reported the error "A subtree cannot specify a different DAV provider than its parent." until I turned off WebDAV under the site's Options tab. Things seem to run well without WebDAV enabled.

    I agree with firecall. I wish Apple would not change the DAV setting in the config file if it has a value other than "On" or "Off".
  • firecall
    Thanks for the tutorial, very handy.

    However if I set any options via the server-admin tool I get "WEB off" set in the .conf file.

    Regardless of if I've used SVNParentPath or SVNPath, as mentioned by Martyn.

    It's annoying, but not something I need to correct often. Apple need to put the subversion config options into the GUI really. Seems like an odd omission - or at least recognise the config change and dont mess with it.
  • Martyn
    Thanks for the tutorial. It was a great starting point. The problem with turning on SVNParentPath is that the Server Admin always switches the DAV svn to DAV OFF. Very annoying. So I used this and it worked a treat. Hope it helps someone else since I was pulling my hair out with the lack of resources. You'd think there's be more people on the Apple Discussions about this but its eerily quiet.

    http://web.mac.com/williamvanetten/Leopard/Leop...
  • good idea -- i've never had a need for multiple repositories, so i haven't tried it.
  • One thing that I like to do is use SVNParentPath instead of SVNPath to put many repositories under one webDav share.
blog comments powered by Disqus