Today i describe the few steps on subversion installation (with repository) on Linux debian. So Subversion in 5 Steps + Apache Mod-DAV. Let's start...
Step 1: Install subversion
If subversion is not installed, install it with:
$apt-get install subversion
Step 2: Create repository
Prepare place for repositories. Standard good palace is /var/svn but i personally prefer /srv/svn. (What is your favorite? Why?)
#create directory $ mkdir /srv/svn/ $ mkdir /srv/svn/java
Create File system-based repository (FSFS) or DB-based. Today state of the art are FSFS repositories.
So just use FSFS based repositories, believe there are many advantages compared to Berkley DB.
#create FSFS repository $ svnadmin create --fs-type fsfs /srv/svn/java
Step 3: Access control
At this point subversion is running and it's the best time to think about user access rights to repositories.
First, create new group for svn users and assign it to your repo. In my case, I've defined one repository special for java projects so I wanna use the special group for that.
$ addgroup svnjava # create new group for java repository #apply that group to the repository location $ chgrp -R svnjava /srv/svn/java
Now change the authorization of the group on the desired repository.
$ chmod -R g+rw /srv/svn/java # group mebers my write $ chmod -R o-rwx /srv/svn/java # other not. $ chmod g+s /srv/svn/java/db # this ensures log-write
Create new Linux users (if not ready) and him to the group
$ useradd aho #new user $ adduser aho svnjava #assigning user to the group
Soon user aho will be able to access subversion repository, but first we have to proceed with the next step.
Step 4: Additional configuration
The repository needs to be configured a little to be useful. Open conf/svnserve.conf in your new repository
$ nano /srv/svn/java/conf/svnserve.conf
and remove comments (#) from these lines.:
anon-access = read auth-access = write realm = My Java Repository
Then save that file.
Step 5: Umask
After previous steps, we have a repository that is suitable for one user but concurrency usage by many users will run into problems by default umask 022.
So the common solution is to make a wrapper invocation of subversion. Let's create a wrapper step by step.
Find where you subversion I currently installed with the following command.
$ which svnserve #returnes me #/usr/bin/svnserve
Now rename original svnserve to svnserve_orig, create new file named svnserve with following:
$ mv /usr/bin/svnserve /usr/bin/svnserve_orig #renamin' of orinignal svn $ touch /usr/bin/svnserve # create new wrapper $ chmod 755 /usr/bin/svnserve #set rights as original
Now add following to new wrapper script svnserve
#!/bin/bash umask 002 /usr/bin/svnserve_orig $*
So we're done!
P.S. See how easy you can move you repository or do backups
UPD! Subversion with Mod DAV
On default svn is not called by a superserver line xindet .d. But it does not matter if you prefer svn+ssh access. In this case you access the svn machine directly through ssh and call svnserve commands virtually direct on remote machine, so don't need to configure anything more.
But, if you have problems with firewalls, witch clients software or just want to have more flexibility, you may be interested in accessing you repository through http:// or https://. In dies case, mod_dav comes in to play.
Mod DAV step by step
1) Install Apache server if not already done it.
$ apt-get install apache2
2) Configure Apache Server
Normally Apache package has all of the common mods including moddavsvn. Debian distribution has a package libapache2-svnwhich registers needed modules for you.
So just install it:
$ apt-get install subversion libapache2-svn
Now all needed modules are registered to Apache. You just have to provide a concrete configuration for your svn repository.
Here is one simple example how I do it I my case. Works fine.
# Check the location of dav_svn.conf then just # copy all following lines to your shell and hit enter. # conf will be appended to dav_svn.conf echo " DAV svn SVNPath /srv/svn/java AuthType Basic AuthName "My Java Repository" AuthUserFile /etc/apache2/svn.pass Require valid-user " >> /etc/apache2/mods-enabled/dav_svn.conf
This configuration is self-explainable.
- SVNPath = Path to repository location,
= is path in acces URL, e.g. http://mydomain/svn/java/
- AuthType Basic = means password based access
- AuthUserFile point to a file with user and passwords.
Red more about Auth Modulif interested in advanced configuration.
3) Now you only need to create some user and passwords.
# -c option is used to create new password file. # Don't use it if create scond user. $ htpasswd -cm /etc/apache2/svn.pass aho
If you try open it now, you'll run into an error. It's because now the svn repository is accessed by a user of the Apache server. Default it would be www-data.
4) So just give him some more rights.
$ adduser www-data svnjava
5) Reload apache configuration. Manual approach
If you are not able to use libapache2-svn, then you have to register the required modules manually:
#make sure your apache is ins /usr/lib64/apache2. adapt path otherways. $ echo "LoadModule dav_svn_module /urs/lib64/apache2/modules/mod_dav_svn.so LoadModule authz_svn_module /urs/lib64/apache2/ modules/mod_authz_svn.so" >> /etc/apache2/conf.d/svn.conf
More information and examples can be found in SVN Book in server-conf chapter.