Setting up a Subversion on Leopard (OS X 10.5)...
16/03/08 14:24 Filed in: Technology
This is much easier in Leopard.
Here's how:
First off, we have to set up Apache2. Prior to Leopard, this was complicated, as Tiger shipped with a 1.x version of Apache, and the Subversion module only worked with version 2. Since Leopard comes with Apache 2 by default, and when you install XCode 3 you get subversion, you have everything you need, and you only have to perform configuration. We'll change the port we liste on from port 80 to port 8008, tell Apache to load the shared libraries that it will need, and setup a "svn" directory location, where we will serve the repository from:
Or we can point our browser at it, by typing in
We could stop there, but currently anyone in the world that knew where our Repository was would be able to download our code, as well as make changes to it. Since this isn't a great idea, we're going to add basic authentication:
Now you have to have a login to check out the code or to check code in. If you were working on an open source project, and wanted everyone to have access to the code, but only registered users to be able to check the code in, you can modify the httpd-svn.conf file appropriately:
And you're done!
When I get around to it, I'll show how to use the SCM features on XCode to connect to your repository, as well as how to add SSL to your repository! Hope you found this useful!
Here's how:
First off, we have to set up Apache2. Prior to Leopard, this was complicated, as Tiger shipped with a 1.x version of Apache, and the Subversion module only worked with version 2. Since Leopard comes with Apache 2 by default, and when you install XCode 3 you get subversion, you have everything you need, and you only have to perform configuration. We'll change the port we liste on from port 80 to port 8008, tell Apache to load the shared libraries that it will need, and setup a "svn" directory location, where we will serve the repository from:
- First, in Terminal,
cd /private/etc/apache2 - Now let's open the file for editing, using the
"vi" editor:
sudo vi httpd.conf(We use vi because it will allow you to save it directly over the existing configuration file, since we are running it with superuser privileges) - In the file, we'll first change the port we'll
listen on from port 80 (the standard http port), to
port 8008:
Listen 80becomesListen 8008 - Next, we have to tell apache to load the
modules we need, specifically the dav svn module,
and the svn authorization module. Conveniently,
these two modules have already been compiled, and
are available in the libexec directory under
apache2, so all we have to do is add them to the
httpd configuration, below the other LoadModule
lines in httpd.conf
LoadModule dav_svn_module libexec/apache2/mod_dav_svn.soLoadModule authz_svn_module libexec/apache2/mod_authz_svn.so
- You'll notice that on the last line of
httpd.conf, that it includes everything in the
"other" directory. So we'll put our svn
configuration file there:
cd othersudo vi httpd-svn.conf<Location /svn>
DAV svn
SVNParentPath /Users/rmartell/repositories
</Location>
- Create the directory we specified in the
httpd-svn.conf file
cd /Users/rmartellmkdir repositoriescd repositories
- Use the svnadmin tool to create the
actual repository:
svnadmin create Sample- Since Apache, by default, runs under the
www account, so does the Subversion server. We
need to give ownership of the files in the
repository to www, so that the server can write
to them
sudo chown -R www Sample
svn list
http://localhost:8008/svn/Sample
Or we can point our browser at it, by typing in
http://localhost:8008/svn/Sample into
the address bar. There is nothing listed currently,
because we have nothing in the Repository yet. I'll
go into adding files (and working with the
repository) in a later post. But you shouldn't see
any error messages!
We could stop there, but currently anyone in the world that knew where our Repository was would be able to download our code, as well as make changes to it. Since this isn't a great idea, we're going to add basic authentication:
cd /private/etc/apche2/othersudo vi httpd-svn.conf- Below SVNParentPath, we add:
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /private/etc/apache2/svn-auth-file
Require valid-user - Now we have to create the authorization file
sudo htpasswd -c svn-auth-file username(we enter our password twice- this is the Subversion user password, not our administrator password!) - That's done, so to test it, we enter into our
browser address bar
http://localhost:8008/svn/Sampleand it will present us with a login box for the Subversion Repository Realm. When we enter our username and password, we will connect!
Now you have to have a login to check out the code or to check code in. If you were working on an open source project, and wanted everyone to have access to the code, but only registered users to be able to check the code in, you can modify the httpd-svn.conf file appropriately:
cd /private/etc/apache2/othersudo vi httpd-svn.conf- Replace
Require valid-userwith
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
And you're done!
When I get around to it, I'll show how to use the SCM features on XCode to connect to your repository, as well as how to add SSL to your repository! Hope you found this useful!