Posts Tagged ‘webdav’

Setting up subversion on unix/linux machine

Subversion is a free/open-source version control system.That is, Subversion manages files and directories, and the changes made to them, over time. It is also known as time machine as you can revert back to any older verion of your data at any time.It has a very pivotal role in code development as it has many features like

1.It keeps track of copy move and delete of fils.

2.It comits the full project ,not the singlefile with commit logs like who comitted.

3.It works across network and all the users can keep their data in a centralized space

4.If some one losts his file or if there is any probem in local computer no need to worry as you can export all your commited work from subvesion.

5.It maintains revision of code in each commit so that you can revert back to your prevous versoin of code reffering to the revision and log.

6.It not only keeps track of your files ,it also keeps track of directories also.

And many more……

The above features I have discussed are basically to make you understand how subverion can help.To know the technical feuture you can refer subersion feature page here.

Setting up subvesion(single instance):-

step-1:Install subversion

You can download your copy of subversion as per your linux/unix distribution from here.

If you want to install from souce you can get the installation guide from here.

As I am using fedora distro I will install using yum

root@host# yum install subversion

Step -2 :Create a folder where your repository will stay.

root@host# $mkdir /repository

step-3:Use svnadmin command to create repo structure

Then we will issue the svnadmin command that creates the structure within this directory that allows us to use it as a repository for files

 root@host# $svnadmin create /repository

This should create a directory structure that looks similar to the following:

root@host# ls -al /repository
total 36
drwxrwxrwx   7 root root 4096 2006-05-19 17:18 .
drwxrwxrwx  14 root root 4096 2006-05-19 17:18 ..
drwxrwxrwx   2 root root 4096 2006-05-19 17:18 conf
drwxrwxrwx   2 root root 4096 2006-05-19 17:18 dav
drwxrwxrwx   2 root root 4096 2006-05-19 17:18 db
-rwxrwxrwx   1 root root    2 2006-05-19 17:18 format
drwxrwxrwx   2 root root 4096 2006-05-19 17:18 hooks
drwxrwxrwx   2 root root 4096 2006-05-19 17:18 locks
-rwxrwxrwx   1 root root  379 2006-05-19 17:18 README.txt

Now that we have a single repository created, we need to allow remote access to it so that users can import their files.

Step-5:- configure svnserve.conf

Go inside conf directory and open svnserve.conf . By deafult guest accounts are allowed write access.To remove the access you need to search for “anon-access”.comment the line by putting a “# ” in the begning.

Step-6:-assign password to the users

In svnserve.conf search for the line containing “password-db = passwd” and uncomment it if commented.Then save svnserve.conf and open the conf/passwd file.You will find a section like below

# harry = harryssecret
# sally = sallyssecret

Below these lines put your username and password like

 kirti = parida

where kirti is the username and parida is the the passwd file and exit.

Step-7:- start the subversion server

To start the subversion server execute the following command from your shell

root@host# svnserve -d -r /repository 

That’s it Your sub version server is up and ready.You can access it by the following link


Special Discussions:

1.If you need to access SVN remotely, by default it runs on port TCP port 3690, so you need to make sure it is open in your firewall.

2.To give different access to different users you can edit the svnserve.conf file and under the general section you can write your rules like below


kirti = write
srikant = read

Where kirti and srikant are users and write or read is their permissions
3.Start Subversion at Startup in quick way:-

In linux to manually start any program edit your /etc/rc.d/rc.local and add that program and the options you want to run on startup.So it will start after all thesystem services started.We can follw that way to start our subversion server .
Step-1:Edit your /etc/rc.d/rc.local file and put something like this in the end

 /usr/local/bin/svnserve -d -r /repository

Done…The next time you will start the server you will get the svn up and running withiut the need to start maually.
It works for sure. But this method have disadvanteges like

a. you can’t manually stop this program at any time just typing /etc/init.d/program stop, or by special Red Hat script – service: service program stop.

b. You can’t activate/deactivate such a program by system tools like chkconfig or setup Red Hat utility. This program will not run correctly according to system ‘run level’.

This method of running program at startup have exactly one advantage – it’s simple

4.Start subversion as a service.

On some systems (like Debian GNU/Linux) this requires us to write an init script so that the server starts up every time the system is rebooted. We would do this by creating a file called svnserve in the /etc/init.d directory, and then editing it to look like the following example file:

#! /bin/sh
DESC="SVN Repository Server Daemon"
test -x $DAEMON || exit 0
OPTIONS="-d -r /cvs/src"
# Get lsb functions
#. /lib/lsb/init-functions
. /etc/default/rcS
start() {
       echo "Starting $DESC... "
       #       echo "Starting $DESC: "
       if ! start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- $OPTIONS
>/dev/null 2>&1; then
               echo $status
               return $status
       log_end_msg 0
       return 0
case "$1" in
       echo "Stopping $DESC: "
       start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
       echo $?
       $0 stop
       sleep 1
       #echo "$NAME."
       echo "Usage: $N {start|stop|restart|force-reload}" >&2
       exit 1
exit 0

Once this file is created and edited to look like the above script, we need to chmod the script to be executable and also set it to startup at boot time:

root@host# chmod +x /etc/init.d/svnserve
root@host# update-rc.d svnserve defaults

Now simply start the service by issuing the following command:

root@host# /etc/init.d/svnserve start
Starting SVN Repository Server Daemon...

We should now be able to connect to the Subversion repository remotely so that we can import files

5.Access subversion using http protocol.

Some times the administers do not want to forward extra port like 3690 used by svn.For that we can access apache through http protocol suing the WebDAV module. From a basic Apache installation, getting WebDAV to work is fairly simple. First, you need to make sure that mod_dav and mod_dav_svn are being loaded in the configuration file for Apache:

LoadModule      dav_module        modules/
LoadModule      dav_svn_module    modules/

Note: In Debian GNU/Linux, the mod_dav is automatically loaded and a part of the Apache2 web server. One simply needs to install the mod_dev_svn module with apt:

root@host# apt-get install libapache2-svn

This will install and automatically configure the module for the Apache2 web server Next we will need to set up a Location directive to point to the repository. In our case, if we want the repository to be referenced with the URL http://IP-ADDRESS/repository, and the repository is located in /repository, you could use the following location directive in the apache2.conf file:

<Location /repository>
  DAV svn
  SVNPath /repository
  AuthType None

Afterwards, simply restart eh Apache2 webserver:

root@host# /etc/init.d/apache2 restart

This will allow us to access the repository remotely with the Subversion client via the webdav protocol. We simply would substitute the svn:// access method with http://.

Note:- Each additional repository that is setup and configured needs its own location directive in the Apache2 configuration file.

Categories: CVS Tags: , , , , ,