Top

How to setup a Subversion server in OS X 10.5 (Leopard)

January 12, 2009 by Sukrit Dhandhania 

Subversion, or “SVN” for short, is a development tool which is a versioned repository for your documents or code. It is allows you to maintain versions of files in an organized manner. Using SVN you can retrieve different versions of documents quite easily. Let’s take a look at how to set it up on Mac OS X Leopard.

  1. Let’s begin by installing SVN. There are a number of ways you can get and install SVN on your Leopard system. The easiest method, the one we will use here, is using XCode. XCode is a set of development tools that ship with your Mac. If you pop in the second DVD that came with your Leopard system, titled “everything else”. You will find the XCode 3 installer on this disk. Double click on it to install. In case you are unable to get your hands on the disc you can also download the XCode 3 installer from Apple’s website. You will, however, need to sign up for the Apple Development Connection program to be able to download XCode 3. The membership is free.
  2. Now let’s do a simple installation of SVN. Remember, this is a basic installation, without a lot of security. I’m assuming here that you are installing this on your machine for only you to use and will not open access to all. To do that you need to add a lot of security, which is beyond the scope of this article.

    Here are steps we are going to follow:

    1. create a local SVN repository
    2. configure the Apache web server to work with SVN
    3. configure Apache to use the repository we created
    4. setup basic authentication for SVN

    1. Let’s create an SVN repository at the location ‘/usr/local/repo’. Launch the Terminal and execute the following command:

      # sudo mkdir /usr/local/repo

      At this point you will be prompted to enter your password. Enter the password you use for the user you are logged in as. Now create a new project called ‘testproject’ in SVN and under the directory we created earlier.

      # sudo svnadmin create /usr/local/repo/testproject

      We need to make sure that the Apache web server can read and write to this repository. So run the following command in the Terminal:

      # sudo chown -R www /usr/local/repo

    2. We now need to configure the Apache web server to work with SVN. Follow the steps carefully, as we are going to be editing the configuration file used by Apache. If done wrong, this can break Apache. Open the Apache configuration file ‘httpd.conf’ in your favorite text editor, for example Vim:

      Scroll down the document till you reach a section where you see a lot of instances of “LoadModule”. Create a new line at the end of this section using the ‘o’ key in Vim, and enter the following:

      # sudo vim /etc/apache2/httpd.conf

      Scroll down the document till you reach a section where you see a lot of instances of “LoadModule”. Create a new line at the end of this section using the ‘o’ key in Vim, and enter the following:

      LoadModule dav_svn_module libexec/apache2/mod_dav_svn.so

    3. Now we will add a separate configuration file for SVN. Scroll down to the end of the document and ad the following line:

      Include /private/etc/apache2/extra/httpd-svn.conf

      Save and exit the file. If you are using Vim then you need to use the following key combination, “ESC + ‘:wq!’ + Enter” to do that. Now open this file using Vim and let’s configure it.

      # sudo vim /private/etc/apache2/extra/httpd-svn.conf

      Enter the following into the file:

      <Location /repo>
      DAV svn
      SVNParentPath /usr/local/repo

      # user authentication
      AuthType Basic
      AuthName “Subversion repository”
      AuthUserFile /etc/users
      # only authenticated users may access the repository
      Require valid-user
      </Location>

    4. Now let’s setup a user for SVN. I’ll create the user calvin and assign him a password. This password protects our Subversion repository.

      # sudo htpasswd -cm /etc/users calvin
      New password:
      Re-type new password:
      Adding password for user calvin

      We’re done now. Hit the url “http://localhost/repo/testproject” in your web browser. You should be prompted for a password here. Enter the username and password you just set. you should be in. You can now create more projects like we created “testproject”.

    To learn more about how to use Subversion checkout the SVN project’s homepage.

    Random Posts

To receive articles like this one delivered directly to your inbox, enter your email address in the field below. You can always opt out of these updates at any time.

Share/Save/Bookmark

Comments

3 Responses to “How to setup a Subversion server in OS X 10.5 (Leopard)”

  1. Jeremy Whitlock on January 12th, 2009 9:50 am

    If you want a more up-to-date Subversion installation, check out this package: http://www.collab.net/downloads/community/. It is a complete Subversion installation packaged in a nice looking, easy to use Apple installer package. Although the details are on the download page, it’s current up to date with the latest Subversion (1.5.5) and includes the following:

    * All server modules (Apache modules for 2.2.x and svnserve)
    * All repository data stores (BDB and FSFS)
    * All language bindings (Java, Perl, Python and Ruby)
    * All supported network layers
    * SASL support

  2. Xeon Xai » Blog Archive » Subversion + Mac OS X Leopard + XCode 3 = Faster Coding on March 4th, 2009 11:20 pm

    [...] How to setup a Subversion server on OS X 10.5 (Leopard) [...]

  3. David Wong on July 21st, 2009 8:46 am

    Thanks for this guide, I tried so many other guides and things wouldn’t link up or weren’t 100% clear.

Feel free to leave a comment...
and oh, if you want a pic to show with your comment, go get a gravatar!





Bottom