Search This Blog

Monday, September 24, 2007

SVN (Sub-Version) Server...

 

Like as i had promised, a step by step guide of what i did to setup a SVN server...

Though i first thought it to be a complicated procedure, it just took me around half hour to completely setup the thing, though i was stranded for the next 20 minutes for i was unable to get a http access to it.  that was entirely my mistake, i did not understand what i read in various articles across the net...  then i had do another research to find another detailed instruction which cleared my doubts.  So if you guys can do it (copy paste and typing a bit faster or even at normal pace. i can guarantee u that you can have a svn server with http access in less than 5 minutes.  Yes it is that easy.  (the time limit is calculated, provided you have all the installation materials downloaded and ready in your system).

Ok. Lets get our hands dirty.

Go here and download the svn zip archive. This is for Apache 2.2.x server.  if you are running Apache 2.0 then go here. In my case i am running Apache 2.2.4 server, and i had downloaded svn version 1.4.5 for 2.2.x Apache version.

Now unzip it and place it is some place where it is easily accessible.  say c:\svn.

Now right click My Computer -> Properties -> Advanced -> Environment Variables, and at the end of the PATH variable add the path of the bin directory of svn.  that would be c:\svn\bin, in my case.  Use the path where you unzipped your copy of the svn.

Now we have to create repositories.  we will assume you will need multiple repositories.  for example, proj1  proj2. now create directories where you will be placing repositories.  eg: c:\svn\repos

proj1 : c:\svn\repos\proj1

proj2 : c:\svn\repos\proj2

now lets create the repositories.

in command prompt type..

svnadmin create C:\svn\repos\proj1

svnadmin create C:\svn\repos\proj2

that is it everything is done.

configuring Apache:

For installing Apache, check out the post on walk thru of the PHPBB installation.

copy the files mod_authz_svn.so and mod_sav_svn.so from the subversion unzipped directory to the modules folder of Apache.

Copy the following dlls too to the modules folder

intl3_svn.dll, libdb44.dll, libeay32.dll,ssleay32.dll.

now open the httpd.conf file

remove comments before these lines.

Loadmodule dav_module modules/mod_dav.so

Loadmodule dav_fs_module modules/mod_dav_fs.so

add these lines

Loadmodule dav_svn_module modules/mod_dav_svn.so

Loadmodule authz_svn_module modules/mod_authz_svn.so

at the end of the config file add this line.

Include c:/svn/subversion.conf.

Users

ok. now lets create users and passwords who can access. go to the bin directory of Apache and type

htpasswd -cm c:\svn\svn-auth-file <name1>

Newpassword *****

Re-type password *****

adding password for user <name1>

use the same procedure to create other users and passwords. do not use the -c switch in the command.  only the first time ever you create a user you will have to use it..

if you want to have annonymous access then u can skip User creation step.

Access Control

Now that we can authenticate our users, we must configure the access rights to our repositories. To do this, we create another file in our etc directory.
C:\svn\svn-acl

#
# specify groups here
#
[groups]
team1 = name1, name2

#
# team1 group has a read/write access to proj1 repository
# all subdirectories
# all others have read access only
#
[proj1:/]
@team1 = rw
* = r

#
# proj2 repository,
#
[project2:/]
name3 = rw
name4 = rw
* = r

#
# name2 is helping with the time zone part of the proj
#
[proj2:/timezone]
name3 = rw
name4 = rw
name2 = rw
* = r

The groups section can be used to define groups of users. For repository project1, only users from the group team1 have read/write access. All other users have read only access.

It is possible to define access for the entire repository, or for specific directory within repository.

SVN COnfig

Now for the config file for Apache. Put this in the subversion.conf file.  you will have to modify it according to your requirements

<Location /proj1>
DAV svn
SVNPath C:/svn/repos/proj1
AuthType Basic
AuthName "Subversion Project1 repository"
AuthUserFile c:/svn/svn-auth-file

Require valid-user

AuthzSVNAccessFile c:/svn/svn-acl
</Location>

<Location /proj2>
DAV svn
SVNPath C:/svn/repos/proj2
AuthType Basic
AuthName "Subversion Project2 repository"
AuthUserFile c:/svn/svn-auth-file

Require valid-user

AuthzSVNAccessFile c:/svn/svn-acl
</Location>

once you finish it that is it. restart apache, and you are ready to go.  type http://localhost/proj1.

 

No comments:

Post a Comment