Installing SVN server on Linux

Apache Subversion (SVN) is a software versioning and revision control system distributed as free software. Developers use Subversion to maintain current and historical versions of files such as source code, web pages, and documentation. Subversion was created by CollabNet Inc. in 2000, and is now a top-level Apache project being built and used by a global community of contributors.


This configuration has been tested on CentOS release 6.2.

This page is largely based on this tutorial from ostechnix.


Some vocabulary

Repository - A database containing the files and change history of your project.
Working tree or Working copy - A local copy of files from a repository.
Revision - The state of the repository at a certain point in time.
Commit - To save your changes back to the repository.
Merge - To combine two sets of changes to the files in your project.
Tag - Identifies a point-in-time snapshot of your project.
Branch - An isolated stream of changes to your project.


Installing SVN

yum install -y subversion mod_dav_svn

this command brough me these two packages:

subversion-1.6.11-12.el6_6.x86_64
mod_dav_svn-1.6.11-12.el6_6.x86_64

This is not latest version, I probably have to do some additiuonal updates before I can get more recent version.


Create a user for SVN

add user and password using Apache's basic authentication. Where svn_user is the name of the new svn user...

# htpasswd -cm /etc/svn-auth-users svn_user
New password: 
Re-type new password: 
Adding password for user svn_user

Create a location to put repositories

svnadmin create Creates Subversion repository.

We will put repository in directory /var/www/svn

# mkdir /var/www/svn
# cd /var/www/svn/
# svnadmin create portal_repo
# chown -R apache.apache portal_repo/

Configure subversion to use specific directory

Indicate that the root directory for your subversion repository wil be /var/www/svn.

# vi /etc/httpd/conf.d/subversion.conf 
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
## Add the following lines ##
<Location /svn>
  DAV svn
  SVNParentPath /var/www/svn
  AuthType Basic
  AuthName "Subversion repositories"
  AuthUserFile /etc/svn-auth-users
  Require valid-user
</Location>
##
## containing Subversion repositories, "/var/www/svn".  Each repository
## must be both:
##
##   a) readable and writable by the 'apache' user, and
##
##   b) labelled with the 'httpd_sys_content_t' context if using
##   SELinux
##
## Example configuration to enable HTTP access for a directory

Stop and Restart Apache

# service httpd stop
# service httpd start
# service httpd status

Test Subversion

Fire up your terminal and enter the following URL http://ip-address/svn/portal_repo in the address bar. Enter the username and password of Subversion user which you have created earlier. You should see your new Subversion repository home page.



Disable anonymous access

If you want to disable the anonymous user to access the repository, just edit the following line in 'portal_repo/conf/svnserver.conf' file.

# vi /var/www/svn/portal_repo/conf/svnserve.conf 
## Line no 12 - Uncomment and Change to 'none' ##
anon-access = none
## Line No 27 - Uncomment to enable acess control ##
authz-db = authz


Create additional links (directories) under Subversion Repository.

Create some sample directories in any place and import them to your Subversion repository.

# cd /var/www
# mkdir subversion-templates
# cd subversion-templates/
# mkdir softwares
# mkdir updates
# mkdir fixes

Create some source code

Create a file called index.html in /var/www/subversion-templates/softwares/
vi /var/www/subversion-templates/softwares/index.html

Import directories

Next we import the sub directories using the command 'svn import'.

svn import — Commit an unversioned file or tree into the repository.

# cd /var/www
# svn import -m 'Initial import' subversion-templates/ http://999.999.999.999/svn/portal_repo
Authentication realm: <http://999.999.999.999:80> Subversion repositories
Username: svn_user
Password for 'svn_user':
Adding         subversion-templates/updates
Adding         subversion-templates/softwares
Adding         subversion-templates/softwares/index.html
Adding         subversion-templates/fixes
Committed revision 1.
SVN Client

Download Tortoise client from http://tortoisesvn.net/downloads.html and install to your PC.