Uli's Web Site
Installing SVNserve on Mac OS X
I recently wanted to install a version control server on a Mac mini and serve it to some other users (you're already using version control, right?), so I investigated around a little. I got recommendations for git and Mercurial, and looked a bit into bazaar which I'd been positively impressed with before, but the simple matter of the fact was that I couldn't find any working GUI clients to use to talk to them, and documentation on installing a server on a Mac wasn't that impressive either.
So, I went back to Subversion, but different from last time I decided to try svnserve. It's a more lightweight setup, but of course lacks the nice HTML browsing experience of Apache2 and WebDAV. Here's the short rundown:
Getting the server
You can find the Subversion server (and the client) on CollabNet's Subversion Community Builds page. It's a simple Mac OS X package installer that installs the command line tools in /opt/subversion/bin, keeping them nicely separate from anything Apple's developer tools might install for you.
Starting the server at login time
Once you've installed svnserve, you'll of course want it to automatically launch whenever a request comes in. It would be annoying to have to open a terminal window and start it every time you restart your Mac. To do that, you can create a launchd launch daemon, which will start up the server as needed. There's a nice description at Joyent's CodeSnippets. Here's what I recommend:
Create a new file org.tigris.subversion.svnserve.plist in /Library/LaunchDaemons. You may have to use sudo pico /Library/LaunchDaemons/org.tigris.subversion.svnserve.plist to create and edit this file, because it's deep in the system folder. This is our Launch Daemon. Write the following in it:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<string>SVN Version Control System</string>
Once you've done that, create a new user (standard user, not an administrator), e.g. using System Preferences, and name it subversion. The server will run as this user, to make it less likely that someone hacking the server can get at your data or administrate your Mac. The UserName entry with the string subversion in our launch daemon above is the name of this user (so if you named it "jeffsubversion", change that line accordingly). The GroupName with the string staff is the group this user is a member of. You can determine this by typing id subversion in Terminal (where "subversion" is the name of the user whose group you're interested in), and then look for "gid" in the output from this command. In my case, it wrote:
uid=502(subversion) gid=20(staff) ...plus a lot more. So, I know that my user's group is staff.
Also note the --root=/Users/subversion/Documents/Repositories part. That is where svnserve will expect us to create our repositories. If you want to, you can even specify an external hard disk there (e.g. /Volumes/MySubversionRAIDArray), or any other partition. If you choose to not use a separate disk, be aware that this means that you could accidentally fill up your startup disk using Subversion and your Mac would then crash because there's no swap space left.
So, log in as your new subversion user for a moment and create the "Repositories" folder using Finder, or just make sure that your external drive is accessible for your user. Once that folder is there and accessible, create your actual repository inside it using a line like:
svnadmin create /Users/subversion/Documents/Repositories/sourcecodeor
svnadmin create /Volumes/MySubversionRAIDArray/sourcecodeWhere "sourcecode" would be the name for this repository. If you have a Mac that is reachable in your local network as http://servermacmini.local, the address for the new repository above would be svn://servermacmini.local/sourcecode. You can create other repositories, e.g. one for your web site, one for your novel etc.
We've now created a repository and installed a server and made sure it launches, however, we still have to do some last set-up work on the server. You see, by default, and for security reasons, the server is locked down. Nobody can write to it. So what you have to do is go into your repository folder and edit the conf/svnserve.conf inside it that svnadmin helpfully created for you. There are a bunch of comments in that file (their lines start with # signs) that explain what what does.
It says the defaults are auth-access = write, this tells the server than write access will be granted to everyone who provides a valid user name and password, and anon-access = read, which means that anyone can read the files even without a user name and password. You might want to change that first line to anon-access = none, if you want only people who have a valid user name and password to see your code in the repository.
Next, remove the "#" and the space at the start of the line password-db = passwd. This, as the comment above tells you, will make svnserve look for a file passwd right next to svnserve.conf as its source of user names and passwords. Save this file and open the file passwd next to it. It contains two sample entries that will seem familiar if you've read The Subversion Book.
Simply replace those entries with username = password pairs of your own and save your changes, and you should be able to access your repository using the URLs mentioned above and the username/password pairs you wrote in this file. All you need to do is restart. Or, if you don't want to restart, you can just log in as an administrator user again and tell launchd that you added a daemon by writing in the Terminal:
sudo launchctl load /Library/LaunchDaemons/org.tigris.subversion.svnserve.plistThe next time you ask for an svn:// URL from this Mac, svnserve will start up and do your bidding. Cool, eh? :-)
Created: 2009-08-01 @963 Last change: 2014-07-25 @469 | Home | Admin | Edit|
© Copyright 2003-2014 by M. Uli Kusterer, all rights reserved.