Advanced SVN – Give SVN a web interface

Install required applications

To do this we will need subversion, libapache2-svn, and of course LAMP stack lamp-server.

# Install lamp-server
sudo apt-get install lamp-server^

# Optional: phpmyadmin and mods for apache
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin
sudo a2enmod vhost_alias rewrite

# Install subversion
sudo apt-get install subversion subversion-tools

# Install libapache2-svn
sudo apt-get install libapache2-svn

Now some more preparation to do.

# SSL
sudo a2enmod ssl

# Regenerate self-signed ssl key if you want
sudo make-ssl-cert generate-default-snakeoil --force-overwrite

Users, folders and groups

Next step we need to add svn usergroups, but not before we fix show all users.

Launch gconf-editor, check “showall” in /apps/gnome-system-tools/users.

Then run Users and Groups in System -> Administration. In Manage Groups, click Add. Name the new group subversion, add yourself and www-data to the member. Log out and log in to activate this.

*Note: all your team members need to be added into subversion group.

The repository

Now, time to create the repository.

sudo mkdir /home/svn
sudo mkdir /home/svn/NEWPROJECTNAME
sudo svnadmin create /home/svn/NEWPROJECTNAME
sudo chown -R www-data:subversion /home/svn/NEWPROJECTNAME
sudo chmod -R 765 /home/svn/NEWPROJECTNAME

# If files under NEWPROJECTNAME/ don't have all group access repeat the previous command again.

Now time to tell apache to set up the access to this repository:

# Add the following content to /etc/apache2/mods-available/dav_svn.conf to make all your repository available. Or add them to each website in /etc/apache2/sites-available

<Location /svn>
 DAV svn
 SVNParentPath /home/svn
 SVNListParentPath On
 AuthType Basic
 AuthName "Subversion Repository"
 AuthUserFile /etc/apache2/dav_svn.passwd
 <LimitExcept GET PROPFIND OPTIONS REPORT>
 Require valid-user
 </LimitExcept>
</Location>

# Restart apache2 after adding the content above
sudo /etc/init.d/apache2 restart

Password protection

# Now, creating the password file.
sudo htpasswd -c /etc/apache2/dav_svn.passwd SVNUSERNAME

# To add more users:
sudo htpasswd /etc/apache2/dav_svn.passwd ANOTHERUSERNAME

# Then you can access to your repository with:
svn co https://hostname/svn/PROJECTNAME PROJECTNAME --username SVNUSERNAME

1 thought on “Advanced SVN – Give SVN a web interface”

Leave a Reply