This is an iEntry.com Website
Search iEntry News

Submit Your Site For Free!

Email Address:
* URL:
*
*Indicates Mandatory Field

Terms & Conditions

LinuxProNews
SecurityProNews
ITmanagement










How To Create An Ubuntu Subversion Server

By Daniele Salatti
Expert Author
Article Date: 2009-03-18

Subversion (SVN) is a version control system initiated in 2000 by CollabNet Inc. It is used to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly-compatible successor to the widely used Concurrent Versions System (CVS).

Subversion is well-known in the open source community and is used on many open source projects, including Apache Software Foundation, KDE, GNOME, FreeBSD, GCC, Ruby, and Tigris.org. Google Code also provides Subversion hosting for open source projects.

Subversion is released under the Apache License, making it free software.

Main features
  • Commits are true atomic operations. Interrupted commit operations do not cause repository inconsistency or corruption.

  • Renamed/copied/moved/removed files retain full revision history.

  • Directories, renames, and file metadata (but not timestamps) are versioned. Entire directory trees can be moved around and/or copied very quickly, and retain full revision history.

  • Versioning of symbolic links.

  • Native support for binary files, with space-efficient binary-diff storage.

  • Apache HTTP Server as network server, WebDAV/DeltaV for protocol. There is also an independent server process that uses a custom protocol over TCP/IP.

  • Branching and tagging are cheap operations, independent of file size, though Subversion itself does not distinguish between a tag, a branch, and a directory

  • Natively client/server, layered library design.

  • Client/server protocol sends diffs in both directions.

  • Costs are proportional to change size, not data size.

  • Parsable output, including XML log output.

  • Open source licensed - "CollabNet/Tigris.org Apache-style license"

  • Internationalized program messages.

  • File locking for unmergeable files ("reserved checkouts").

  • Path-based authorization.

  • PHP, Python, Perl, and Java language bindings.

  • Full MIME support - the MIME Type of each file can be viewed or changed, with the software knowing which MIME types can have their differences from previous versions shown.

Let's begin

Installation is straightforward. All the packages you need are available in the official Ubuntu repositories.

The first step is to install subversion itself:

view sourceprint

1.sudoapt-get update
2. 
3.sudoapt-get installsubversion

Next step is to create a repository. We will use this repository (named "repo") for testing purposes. Usually I put my repositories in /var/svn when I set up a Subversion server, but you may change it at your convenience.

view sourceprint

1.cd/var
2. 
3.sudomkdirsvn
4. 
5.sudosvnadmin create /var/svn/repo

To control who has access to the repository, we will add a user who will own all the repository files. This will also add a group with the same name as the user.

view sourceprint


1.sudoadduser --system --no-create-home  --group svn

This will create a user with no password (you will not be able to perform a log-in with the user "svn"), uses the right UIDs for system accounts, and skips creating the home directory (we don't need it).

Now change the ownership of the repository files with the following command:

view sourceprint
1.sudochown-R svn.svn /var/svn

In order for your users to be able to access the repository you need to add them to the svn group. If you skip this step your users wont be able to write in the repository. When you are done you need to install an ssh server, because clients will connect using ssh.

view sourceprint
1.sudoapt-get installopenssh-server

Now you should be able to connect to the repository using ssh:

view sourceprint
1.svn co svn+ssh://username@youservername/var/svn/repo

Subversion also supports the WebDAV protocol. To take advantage of this you need to install the Apache Web server.

Setting up Apache

Assuming that Apache is already installed on your server (I will not cover the necessary step here), you have to install the libapache2-svn package:

view sourceprint
1.sudoapt-get installlibapache2-svn

I'm going to show you how to add the repository to Apache's default virtual host. This is not recommended in a real production environment - it would be better to create a new virtual host.

Open the default virtual host file:

view sourceprint
1.cd/etc/apache2/sites-enabled
2. 
3.sudovi000-default

Append in the directive the following:

view sourceprint
1.DAV svn
2. 
3.SVNPath /var/svn/repos

Then restart Apache:

view sourceprint
1.sudo/etc/init.d/apache2 force-reload

Open your browser: you should be able to see your repository at the URL http://yourservername/svn/repo.

Securing the Web access

I guess you don't you want everyone to be able to access your repository, isn't it? Ok. I'm going to show you how to prevent anonymous access to your new repository.

Append this to the location directive (right below the text you entered a minute ago):

view sourceprint
1.AuthType Basic
2.AuthName "Subversion Repository"
3.AuthUserFile /etc/apache2/passwords
4.Require valid-user

Add a user name and password to the Apache password file:

view sourceprint
1.sudohtpasswd -cb /etc/apache2/passwords youruser yourpassword

Once again, restart Apache:

view sourceprint
1.sudo/etc/init.d/apache2 force-reload

If you visit the repository URL again you will be asked to enter the username and password.

Comments

About the Author:
Daniele Salatti is a 23 years old Italian guy. Informatic Engineering student at the University of Pisa, he is a passionate Linux user. Check out his blog at Salatti.net.



Newsletter Archive | Article Archive | Submit Article | Advertising Information | About Us | Contact