Skip to content

Posts tagged ‘WebDAV’

5
May

Installing Subversion With Apache and DAV In Ubuntu 8.10

Subversion (SVN) is a version control system initiated in 2000 by CollabNet Inc. It is used to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly-compatible successor to the widely used Concurrent Versions System (CVS) [Wikipedia]

I have adopted subversion to manage my PhD thesis and other research related tasks. Here is how I setup SVN server on my Ubuntu 8.10 server.

Installing subversion

First of all, we need to install the necessary packages to put SVN on to the server

sudo apt-get install subversion libapache2-svn

Now that SVN in on the server, the next step is to create a user who has rights to manage SVN repositories.

SVN users and groups

There are severel ways to set permissions on the repository. As I already have a username, say ‘mark’, on my server, the best thing to do would be to create a group called ‘subversion’ and add myself to it. I am also planning to access my repositories via http, so it is necessary to add the user ‘www-data’ to the ‘subversion’ group. All this can be done by following the commands below.

sudo addgroup subversion
sudo adduser mark subversion
sudo adduser www-data subversion

Logout and login again before continuing further.

Creating a SVN repository

The next thing to do is to chose a location for creating SVN repositories. I like to create my repositories at /home/svn. Follow the commands below to create a SVN repository.

sudo mkdir /home/svn
sudo mkdir /home/svn/research
sudo svnadmin create /home/svn/research

This will create the repository ‘research’ under /home/svn. Note that this repository will/should have the root:root user and group permissions.

Configuring SVN access via WebDAV protocol (http://)

To access the SVN repository via WebDAV protocol, configure the Apache2 web server. To do this edit the /etc/apache2/mods-available/dav_svn.conf file to look like:

DAV svn
SVNPath /home/svn/research
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/svn/htaccess

Require valid-user
Now WebDAV has to be provided with the user access details as it is going to control the reading and writing to the repository:

cd /etc/svn
sudo htpasswd -c -m htpasswd mark

Any additional users has to be added without the ‘-c’ switch so as to avoid overwriting the ‘htaccess’ file. Afterword restart apache by issuing:

sudo /etc/init.d/apache2 restart

Test the configuration by typing http://localhost/svn in a browser. Enter the username and password and now the repository can be seen.

Creating further repositories and projects

Further repositories may be constructed inside the research repository, provided users of the ‘subversion’ group should have their ownership. The following commands can achieve the same.

sudo mkdir /home/svn/research/thesis
sudo chown -R mark:subversion /home/svn/research/thesis
sudo chmod -R 777 /home/svn/research/thesis
svnadmin create /home/svn/research/thesis

A sample SVN repository structure

A sample SVN repository structure

Once that is done, its time create a project and add it to the repository so that SVN can manage it. Before that, its better to have a look at the ‘usual’ subversion project directory structure [Refer figure]. In SVN, a project directory usually has 3 subdirectories; trunk, tags and branches. Trunk contain the most recent working copy of the project, tags contain copies of the working directory of some importance (such as the copy of the thesis version that was submitted to your supervisor to have a look at) and branches contain snapshots of the working copy from which you decided to follow a different route.

All said, the final decision about the directory structure rests upon the user. Now the idea is to create a skeletal directory structure somewhere in your home directory and import it to the thesis repository. Follow the commands below to establish this.

cd ~
mkdir thesis
mkdir thesis/trunk
mkdir thesis/tag
mkdir thesis/branches
svn import thesis/ http://localhost/svn/research/thesis/

Now check repository again via the browser and project can be seen added inside. The skeletal directories can be deleted now. A working copy of the project can be created by issuing the commands:

cd ~
svn checkout http://localhost/svn/research/thesis

Files can be added to the repository by:

cd ~ cd thesis/trunk/

touch File_A.py
svn add File_A.py
svn commit -m "Initial import of the File_A.py file for versioning"

Check again via the browser to see the file.