The Perfect Subversion Server - Debian Lenny [ISPConfig3]

Want to support HowtoForge? Become a subscriber!
 
Submitted by indemnity83 (Contact Author) (Forums) on Fri, 2010-05-14 14:20. :: Debian | ISPConfig | Apache

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.

 

Requirements

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.

 

Install Subversion

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):

mkdir /var/clients/clientx/weby/svn

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.

  1. 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.
  2. 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.
  3. 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).

 

Public Repo

	<Location /svn/myrepo>
DAV svn
SVNPath /var/clients/clientx/weby/svn/myrepo
</Location>

Shared Repo

	<Location /svn/myrepo>
DAV svn
SVNPath /var/clients/clientx/weby/svn/myrepo
AuthType Basic
AuthUserFile /var/clients/clientx/weby/svn/myrepo.passwd
<LimitExcept GET OPTIONS PROPFIND REPORT>
Require valid-user
</LimitExcept>
</Location>

Private Repo

	<Location /svn/myrepo>
DAV svn
SVNPath /var/clients/clientx/weby/svn/myrepo
AuthType Basic
AuthName "Indemnity83 Scripts"
AuthUserFile /var/clients/clientx/weby/svn/myrepo.passwd
Require valid-user
</Location>

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)'

 

Thanks

I hope you find this how to useful. Please feel free to add comments or corrections.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by K4c (not registered) on Tue, 2014-05-13 09:49.

As default ispconfig does not allow to put new folder under .../clientx/weby dir i would suggest doing this way:

Create folder /clientx/weby/web/svndir

Make this folder protected in your ispconfig panel.

Add protected user to this folder.

Now add options to Your apache config, sth like this:

<Location /svn/repo1>
DAV svn
SVNPath /var/www/clients/client1/web1/web/svndir/repo1
        AuthType Basic
        AuthName "Dev only"
AuthUserFile /var/www/clients/client1/web1/web/svndir/.htpasswd
Require valid-user
</Location>

After creating repo You have to add write for group permission to this folder.

 Now You can manager Your users from ispconfig panel. I think it is a better option. It took me 2 hours to figure it out, so I hope this share will help someone.

Submitted by Anonymous (not registered) on Thu, 2011-02-17 20:48.

Great tutorial, but you appear to have made a mistake in a number of your paths:

 You have "/var/clients/"

 When it should be "/var/www/clients/" to make it all work

Submitted by Anonymous (not registered) on Sat, 2011-01-01 14:15.
How are the permissions set? I tried it, but i had to set chmod 777 in order for eveything to work, which is undesirable
Submitted by Ted Jardine (not registered) on Tue, 2012-05-01 17:42.
Assuming you need to make sure SuExec is enabled?
Submitted by Anonymous (not registered) on Fri, 2010-05-14 18:01.

You put a lot of great work into a somewhat archaic piece of technology. I'd rather use something modern like

http://sunoano.name/ws/scm.html#provide_a_git_repository_to_the_public

Submitted by Anonymous (not registered) on Tue, 2010-05-18 09:16.
GIT and subversion have two very different usage modes.  subversion solves some problems which git does not address and vice verse.  One is not archaic simply because it does not support the same behavior as another.
Submitted by vberry.net (not registered) on Tue, 2014-05-13 09:26.

Even with suexec enabled  i had to add write permission for group like that:

chmod -R g+w ./svn

Nice article.