DarwinPorts and Subversion on Mac OS X

This is a recap of instructions posted by Bill Bumgarner (here and here) and James Duncan Davidson (here), on installing Subversion and Apache2 via DarwinPorts on Mac OS X 10.3.

Install DarwinPorts

Get DarwinPorts from CVS and build and install it. Assuming default installation locations are okay, this script should work:


cvs -d :pserver:anonymous@anoncvs.opendarwin.org:/Volumes/src/cvs/od login cvs -d :pserver:anonymous@anoncvs.opendarwin.org:/Volumes/src/cvs/od co -P darwinports cd darwinports/base ./configure make sudo make install

Now you need to add the DarwinPorts binaries directory to your PATH. Depending on whether you prefer sh-like shells such as bash or csh-like shells, one of the following should work:

export PATH=$PATH:/opt/local/bin
set path=($path /opt/local/bin)

Install subversion and apache2

Next, using James's instructions as a guide, configure and install subversion and apache2. To do so, run the following script using sudo:

port install apache2
port install subversion +mod_dav_svn +python
port install DarwinPortsStartup

Note a small problem here: This script installs subversion Python bindings, but only for a non-framework installation of Python. If you need bindings for a framework installation of Python, you're on your own.

Create The Repository

Bill created his subversion repository in /svn. I wanted mine in /usr/local/svn-repository, for no good reason.

$ sudo mkdir /usr/local/svn-repository
$ sudo svnadmin create --fs-type fsfs /usr/local/svn-repository/master
$ sudo chown -R www /usr/local/svn-repository

Patch httpd.conf

Bill has provided a patch for httpd.conf. It assumes that your subversion repository resides in /svn. If it resides elsewhere you'll need to change the patch file before applying it.

For example, since I put my subversion repository in /usr/local/svn-repository I had to change every reference to the /svn filesystem location in the patch file to point to /usr/local/svn-repository.)

You can copy the patch file to /opt/local/apache2/conf, and then apply it from there. Patch will ask you if it should assume this is a reverse patch (-R). Say 'y':

$ sudo cp my-httpd-conf-svn.patch /opt/local/apache2/conf/
$ cd /opt/local/apache2/conf/
$ sudo cp httpd-std.conf httpd.conf
$ sudo patch httpd.conf my-httpd-conf-svn.patch
patching file httpd.conf
Reversed (or previously applied) patch detected!  Assume -R? [n] y

Add Repository Users

$ cd /usr/local/svn-repository/
$ sudo -u www htpasswd -c master-auth mitch
New password:
Re-type new password:
Adding password for user mitch

Test The Apache2 Configuration

$ /opt/local/apache2/bin/apachectl configtest
Syntax OK

Start Apache2

It should start up, listening on port 8000.

$ sudo /opt/local/apache2/bin/apachectl restart
httpd not running, trying to start

At last you should be able to view the topmost directory of the (empty) subversion repository in your web browser, by loading http://localhost:8000/svn/.