Creating SVN repositories on my Ubuntu virtual server
If you’re developing applications you will need a versioning tool sooner or later, even if you’re not working in a team. Its backup functions and the ability to review any changes on your code is something you never want to miss again. Since it’s not too easy to set up an SVN repository, here’s a step-by-step tutorial how I did on my virtual server. I basically followed this german tutorial from the ubuntuusers.de wiki.
Installing the necessary packages
sudo apt-get install subversion libapache2-svn
Make directories for your repository
The following is just an example, you can change your directory but remember to keep your directory through this tutorial.
sudo mkdir -p /var/www/svn/myproject
Create repository via svnadmin tool
sudo svnadmin create --fs-type fsfs /var/www/svn/myproject
Change ownership of this directory to your default apache user
By default this is www-data:www-data on Ubuntu
sudo chown -R user:group /var/www/svn/myproject
Optional: Setting permissions of the directory
If you face a “permission denied” error when doing your initial import later, you have to change the permissions for this directory
sudo chmod -R 775 /var/www/svn/myproject
Add a location to your dav_svn.conf
vi /etc/apache2/mods-enabled/dav_svn.conf
and add the following entry:
<Location /myproject> DAV svn SVNPath /var/www/svn/myproject # Add this if you want committers to authenticate themselves AuthType Basic AuthName "Subversion Repository" AuthUserFile /etc/apache2/my.passwd # The following three lines allow anonymous read, but make # committers authenticate themselves. <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> </Location>
Create a password file for commiters
htpasswd2 -c /etc/apache2/dav_svn.passwd user
Restart your server
/etc/init.d/apache2 restart
Congratulations! Point your browser to http://yourserver.com/myproject and enjoy your SVN repository!