The Perfect Subversion Server - Debian Lenny [ISPConfig3]
Subversion is a free/open-source version control system. That is, Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of "time machine". This guide will help you setup the subversion system, and integrate it with your existing ISPConfig3 installation allowing you control over disk usage, quota and other factors in a very familiar way. Perhaps one day, somebody can use this process to create a plug in for ISPConfig3 that does all of this automatically.
Obviously, this how-to requires that you already have ISPConfig3 setup and running. The steps outlined below may work with ISPConfig2 as well, but it has not been tested and will not be supported. If you haven't already done so, follow falko's guide to The Perfect Server- Debian Lenny [ISPConfig3] before continuing.
To allow for a single web site to have multiple repositories, we'll be putting everything under a 'svn' folder, and ultimately the public path to your repository will look something like http://example.com/svn/myrepo. But before we can get started, you need to create the site for 'example.com'. Creating the site and setting quota options is outside the scope of this how-to, but its fairly straight-forward if you haven't done it before.
Installation of Subversion, and the required Apache module(s) is fairly straight forward (run as root, or use sudo):
apt-get install subversion libapache2-svn
Create a Repo(sitory)
By default, ISPConfig stores the sites in /var/clients/clientx/weby/, you'll need to know which client ID (x) and site ID (y) corresponds to the site you want to setup the repository on. If you've made any adjustments to the default paths you'll need to modify the commands below to match your directory structure. Start by creating the svn directory (you only need to do this once for each site):
Next, you'll need to create the repository and correct the permissions on everything (important for quota checks).
svnadmin create /var/clients/clientx/weby/svn/myrepo
chown -R weby:clientx /var/clients/clientx/weby/svn
chmod -R 770 /var/clients/clientx/weby/svn
Sharing and Securing the Repository
We will be using apache to share and secure access to our repository and while the sharing steps are always the same, we have three options for securing the repository.
- Public Repository - A public repository means that any user can download and browse (checkout) and upload (commit) files at any time without restriction. This is generally not a recommended way to deploy a repository as it can lead to vandalism of your code.
- Shared Repository - A 'shared' repository means that anybody can download and browse (checkout) the code, but only authorized users can make commits to the repository. This is the most common method of securing a repository, similar to how sites like Sourceforge and Google Code share data.
- Private Repository - A private repository means that any action against the repository requires an authenticated user and is useful when the code is not meant to be shared or Open Source.
Assuming you choose either a shared or private repository, you'll need to create the passwords file that stores usernames and passwords of 'authorized' users (to add additional users, omit the '-c' option from the command).
htpasswd -c /var/clients/clientx/weby/svn/myrepo.passwd [username1] <-- you'll be asked to enter a password for username1
Finally, you need to add the appropriate directive to tell Apache what to do when a user requests http://example.com/svn/myrepo. Depending on the security method you wish to use, copy the appropriate directive below and paste it in the 'Apache Directives' box, on the 'Options' tab of your site in ISPConfig (don't forget to fix the directories with the appropriate x and y values).
<LimitExcept GET OPTIONS PROPFIND REPORT>
AuthName "Indemnity83 Scripts"
It may take a minute for the site to start working once you make the changes, but at this point you should have a working and secured Subversion repository. If you want to add more, just repeat everything starting at 'Create a Repo(sitory)'
I hope you find this how to useful. Please feel free to add comments or corrections.