ubuntu subversion server setup

How To Create An Ubuntu Subversion Server

By Daniele Salatti

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.sudo apt-get update
2. 
3.sudo apt-get install subversion

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.sudo mkdir svn
4. 
5.sudo svnadmin 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.sudo adduser --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).
(set password is you want # sudo passwd svn)

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

view sourceprint
1.sudo chown -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 .
(# usermod -a -G svn <existing username> or useradd -G {group-name } new username )

view sourceprint
1.sudo apt-get install openssh-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:

To install subversion, open a terminal and run the following command:

sudo apt-get install subversion libapache2-svn

We’re going to create the subversion repository in /svn, although you should choose a location that has a good amount of space.

sudo svnadmin create /svn

Next we’ll need to edit the configuration file for the subversion webdav module. You can use a different editor if you’d like.

sudo gedit /etc/apache2/mods-enabled/dav_svn.conf

The Location element in the configuration file dictates the root directory where subversion will be acessible from, for instance: http://www.server.com/svn

<Location /svn>

The DAV line needs to be uncommented to enable the dav module

# Uncomment this to enable the repository,
DAV svn

The SVNPath line should be set to the same place your created the repository with the svnadmin command.

# Set this to the path to your repository
SVNPath /svn

The next section will let you turn on authentication. This is just basic authentication, so don’t consider it extremely secure. The password file will be located where the AuthUserFile setting sets it to…  probably best to leave it at the default.

# Uncomment the following 3 lines to enable Basic Authentication
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/dav_svn.passwd

To create a user on the repository use, the following command:

sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd <username>

Note that you should only use the -c option the FIRST time that you create a user. After that you will only want to use the -m option, which specifies MD5 encryption of the password, but doesn’t recreate the file.

(use "htpasswd" is "htpasswd2 command not found")

Example:

sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd geek
New password:
Re-type new password:
Adding password for user geek

Restart apache by running the following command:

sudo /etc/init.d/apache2 restart

Now if you go in your browser to http://www.server.com/svn , you should see that the repository is enabled for anonymous read access, but commit access will require a username.

If you want to force all users to authenticate even for read access, add the following line right below the AuthUserFile line from above. Restart apache after changing this line.

Require valid-user

Now if you refresh your browser, you’ll be prompted for your credentials:

You now have a working subversion server!

 

Before you start using Subversion, make sure you make the repositories owned by Apache. Apache is the one who wil access the repositories physically. This is really easy:

$ sudo chown -R www-data.www-data /var/lib/svn
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值