Company dedicated to web development, graphic design, photography and web hosting.

How to install svn server
Published Monday, 15th of August 2011
Overview How to install your own svn server. Subversion (svn) is a software versioning and a revision control system. It helps to maintain current and historical versions of your files, usually source code. The installation of svn 1.6.11 was performed on CentOS 5.6 64 bits via command line.Alias table
VariableExampleDescription
${REPOS_PATH}/usr/local/svn/reposThe path to the repository folder
${SVN_USER_NAME}ochounosUser with access to the server
${SVN_USER_PWD}passPassword for the user
${SVN_PORT}3690Port where listen the svn server
Steps to follow Package installation
  1. First, we need to install the subversion package. We can do it easily with yum. Just install the subversion.x86_64 package (or subversion.i386 for 32 bits architectures):
    yum install subversion.x86_64
    Maybe some dependences are required to be installed also with this package.
Repository creation
  1. Create the repository using svnadmin:
    svnadmin create ${REPOS_PATH}
    The folder will be created if not exists.
Configure repository
  1. Under the folder created there is a structure of files. First at all we need to configure this repository instance. This configuration is located in some files under the folder ${REPOS_PATH}/conf. Go there.

    The main configuration will be located in svnserve.conf. We can change some values for our instance. Some of them that could be interesting to modify are:
    1234567891011
    # no access for anonymous users
    anon-access = none
    # read/write access for logged users
    auth-access = write
    # the file where passwords will be stored
    password-db = passwd
    # the file where users will be stored
    authz-db = authz
  2. Now we need to add an user to the list of users that access to the server. We need to modify the file authz and add the next line:
    1234
    # give access to the user for read and write to the folder /
    # / means all the repository
    [/]
    ${SVN_USER_NAME} = rw
    We can give access per folder (which includes branches, tags, trunk and subfolders) and assign permissions for read and write using the letters r and w respectively.

  3. And we need to specify the password for this user. We need to modify the file passwd and add the next line:
    1
    ${SVN_USER_NAME} = ${SV_USER_PWD}

  4. The access for the user root (and others) is disabled by default and is discouraged to use the root user for access to the server.
Configure firewall
  1. We can check if any other process is listening in the port that we are trying to use runnig the next command:
    netstat -apnt | grep ${SVN_PORT}
    Verify that no other process is listening in the same port that you are planning to use.

  2. Now we need to open the port in the firewall, using iptables, launching the next command:
    iptables -I INPUT -p tcp -m tcp --dport ${SVN_PORT} -j ACCEPT
  3. And we need to save the changes, so they will be applied next time that the machine starts:
    service iptables save
Configure svn as service
  1. We can run the svn as service, so it will be launched when the machine is started. We can add this service at level 3, but the problem is that the default configuration is not taken our repository as default repository to serve. We need to add our configuration to the file used as configuration file for the script /etc/init.d/svnserve. This script uses the file /etc/sysconfig/svnserve, so we need to add a line in this file:
    1
    OPTIONS="-r ${REPOS_PATH}"
  2. And finally we need to add this service to the level 3:
    chkconfig --levels 3 svnserve on
  3. Next time, when the machine starts, will launch svnserve at level 3 listening in the port specified and using our repository. But in case you want to launch the server right now, you don't need to restart, just run the next command:
    service svnserve start
Remote access
  1. You can use any svn client to acces to your server and repository. Just remember to use the protocol svn:// and not http://, so specify svn://yourdomain.com as url for your svn server.

  2. You can specify also some subfolder in your url using svn://yourdomain.com/trunk for example, or any other subfolder as svn://yourdomain.com/trunk/subfolder1/subfolder2.
References http://subversion.apache.org/


Back to the list of entries