Monday, December 3, 2012

Install and Configure Subversion in Linux


Before Installing Subversion check whether berkely db is installed. For Berkely db installation check Berkely db installation

Download and Install subversion-1.4.6
 
wget http://subversion.tigris.org/downloads/subversion-1.4.6.tar.gz 

tar -zxvf subversion-1.4.6.tar.gz
 
cd subversion-1.4.6
[root@test]./autogen.sh
You can run ./configure now.

Running autogen.sh implies you are a maintainer.  You may prefer
to run configure in one of the following ways:

./configure --enable-maintainer-mode
./configure --disable-shared
./configure --enable-maintainer-mode --disable-shared

Note:  If you wish to run a Subversion HTTP server, you will need
Apache 2.0.  See the INSTALL file for details.
 
run the below commands to complete the installion 
 
 ./configure --with-berkelay-db=/usr/local/bkdb
 make
 make install 

Here bkdb is the folder where i installed bkdb

Before running svn commands check the modules are correctly installed or not for the subversion

check this line are there in /etc/httpd/conf/httpd.conf file

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
 
or install it using the below command and enter the above lines in the http conf file.
 
yum install mod_dav_svn
 
check the modules are entered in apache config file 
 
[root@GAI-1397 subversion-1.4.6]# /etc/init.d/httpd start
Starting httpd: [Sun Nov 25 11:36:53 2012] [warn] module dav_svn_module is already loaded, skipping
[Sun Nov 25 11:36:53 2012] [warn] module authz_svn_module is already loaded, skipping
                                                           [  OK  ]

Now create one repository with svnadmin command.Run this command inside your subversion folder.

[root@test subversion-1.4.6]# cd
[root@test ~]# mkdir /test/
[root@test ~]# svnadmin create /test/repos
[root@test ~]# cd /test/repos
[root@test repos]# ls
conf  dav  db  format  hooks  locks  README.txt

This full path you have to specify in SVNPath.
[root@test repos]# pwd
/test/repos

Then at the end of the httpd.conf file you have to add 
 
#for svn path
<Location /test/repos>
DAV svn
SVNPath /usr/local/src/subversion-1.4.6/repos
</Location>
restart apache
 
Now import a sample file using the below command 
 
[root@test ~]# svn import -m  "2initial import." file:///usr/local/src/subversion-1.4.6/repos 
 
Check the logs using below command
 
 [root@test repos]# svn log file:///usr/local/src/subversion-1.4.6/repos
------------------------------------------------------------------------
r1 | root | 2012-11-25 12:25:22 +0530 (Sun, 25 Nov 2012) | 1 line

2initial import.
------------------------------------------------------------------------
http://localhost(you have to give your domain name)/test/repos

Now you are ready to checkout the files with any svn client.  


 
For security purpose to give authentication to the user we have to create authentication file with the command, 
  
[root@test ~]# htpasswd -cm /etc/svn-auth-file test
New password:
Re-type new password:
Adding password for user test

[root@test ~]# cat /etc/svn-auth-file
test:$apr1$yal.A/..$vXSzgm19LKem9i6RIOUon/
 
And to specify which access you want to give the user, create svn-access-file inside /etc.

Inside this file add code as,

[/]
* = rw

add these lines in the http configuration location folder

SVNPath /usr/local/src/subversion-1.4.6/repos
AuthzSVNAccessFile /etc/svn-access-file
AuthType Basic
AuthName “test”
AuthUserFile /etc/svn-auth-file
Require user user_name

[root@test ~]# chkconfig svnserve on
[root@test ~]# /etc/init.d/svnserve start

[root@test ~]# egrep --iw 'User|Group' -color=auto /etc/httpd/conf/httpd.conf
User apache
Group apache

[root@test ~]# chown -R apache:apache /usr/local/src/subversion-1.4.6/repos/

You can also specify the setting for https in  vi /etc/httpd/conf.d/subversion.conf
 
You can create multiple repos and specify with the above syntax in subversion or apache configuration file.
 
We can now co from other servers using smart svn and also we can download it through http using the below url
 
http://localhost/test/repos 
 
 
 

No comments: