To get subversion+apache2 work on Debian is not very difficult. Basically including the following steps (ref: this post):

  1. sudo apt-get install apache2 subversion libapache2-svn
  2. sudo a2enmod dav_svn (load the svn module)
  3. sudo nano /etc/apache2/mods-enabled/dav_svn.conf (edit this file to specify the actual svn repositories path and setup basic user authentication)
  4. sudo mkdir /var/svn-repos ;sudo svnadmin create /var/svn-repos (create svn repository)
  5. sudo chown -R www-data:www-data /var/svn-repos; sudo chmod -R 770 /var/svn-repos (give right permission to apache server. This is crucial  for browsing the svn repos via web browser. Some articles suggest creating a new group ‘subversion’ and add all svn user to that group, but I found that’s not the best solution to use svn+ssh protocol and websvn together. Then we can use ‘adduser’  command to create new users, and add them to the group ‘www-data‘ using ‘usermod -G www-data user_name’ command. Without this step, the users cannot update or commit via http or svn+ssh because only the users in www-data group can access the repos with permission 770 set above. I also found this is a workaround for the SSH permission problem due to the owner change when codes are committed by specific users, because all the svn users are now the members of www-data group and they all have access to the repos due to group policy, although the ownership can change to the user who commits codes if svn+ssh protocol is used. If users commit codes via http, the ownership of the repo folders will not change and  always belongs to the ‘www-data’ user. )
  6. sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd bob (Add a user ‘bob’ to allow browsing the svn repo. Bob should be in the subversion group. This command will ask to input user password.Note:remember the path of this file, we will use it again when we set up websvn.)
  7. sudo /etc/init.d/apache2 restart (restart apache to enable the new settings.)
  8. Now we should be able to access the svn repo via http://hostname/svn/repo_name (the path depends the settings in /etc/apache2/mod-available/dav_svn.conf. Note the ‘SVNParentPath’ setting.)

Next let’s get websvn alive:

  1. sudo apt-get install websvn enscript (The later is used to colorize the codes. During the installation, websvn will ask for the parent path of all repos and apache support.)
  2. edit /etc/websvn/config.php, /etc/websvn/wsvn.php, /etc/websvn/apache.conf and /etc/websvn/svn_deb_conf.inc (config.php contains the default settings, it calls svn_deb_conf.inc to get specific settings for Debian. In config.php we could control the template to use, folding behavior, language, coloring and etc. But DO NOT active the $config->useAuthenticationFile line, we will configure the user authentication later in /etc/websvn/apache.conf .wsvn.con and svn_deb_conf.inc contain the information obtained during the installation of websvn, their default values should work fine.)
  3. add user authentication to apache.conf (just before the ending </Directory> tag)#modifiedAuthType Basic

    AuthName “websvn”

    Require valid-user

    AuthUserFile /etc/apache2/dav_svn.passwd  #(this file is the same one we created when we set up subversion.)

    #end modification

  4. type http://hostname/websvn to test the new setup. (‘websvn’ is an apache alias of the actual websvn section in apache.conf. )

PS: ‘blame’ view in websvn shows line numbers, revision and author for each line. With these info viewers can easily figure out who made what change, and whom they should blame if some wrong codes or rubbish are found.

Attachment: websvn_files

ref1

ref2