Thursday, January 26, 2012

HOW TO INSTALL SUBVERSION WITH APACHE ON LINUX (svn server)


  • Log as root user in to your system
[root@pasindu ~]# yum search subversion


  • We need to install following packages .
subversion-devel.i686
subversion.i686
subversion-libs.i686


[root@pasindu ~]# yum install subversion-devel subversion-libs subversion

Your subversion installation done. Now we have to configure subversion Apache compatibility using mod_dav_svn. we assume  Apache server already installed .
if not  ...  [root@pasindu svn]# yum insatll http


After that we need to install mod_dav_svn package to our Apache server 

[root@pasindu ~]#yum install mod_dav_svn


  • configuring Apache Server
[root@pasindu ~]# vim /etc/httpd/conf/httpd.conf
add following two lines
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
 

Make sure you will add these lines after LoadModule dav_module


[root@pasindu ~]# /etc/init.d/httpd configtest
[root@pasindu ~]# /etc/init.d/httpd restart


  • Creating svn repos using  svnadmin command 
[root@pasindu var]# svnadmin create repos
[root@pasindu var]# ls -aslt | grep repos
4 drwxr-xr-x   6 root root  4096 Jan 26 12:02 repos
 
[root@pasindu var]# ls repos/
conf  db  format  hooks  locks  README.txt

[root@pasindu var]# chown apache:apache /var/repos



  • Then at the end of the httpd.conf file you have to add
[root@pasindu var]# vim /etc/httpd/conf/httpd.conf
#for svn path
<Location /svn/repos>
DAV svn
SVNPath /var/repos

<Location>

[root@pasindu ~]# /etc/init.d/httpd configtest
[root@pasindu ~]# /etc/init.d/httpd restart


  • configuring  Authentication 

[root@pasindu var]# htpasswd -cm /var/svn/svnuser pasindu
htpasswd: cannot create file /var/svn/svnuser
[root@pasindu var]# mkdir /var/svn
[root@pasindu var]# htpasswd -cm /var/svn/svnuser pasindu
New password:
Re-type new password:
Adding password for user pasindu



  • Configuring svn policy files 


[root@pasindu var]# vim svn/svnpolicy


[/]
* = rw



You can specify this inside httpd.conf file as,
<Location /svn/repos>
DAV svn
SVNPath /var/repos
AuthzSVNAccessFile /var/svn/svnpolicy
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /var/svn/svnuser
Require user user_name

</Location>



[root@pasindu ~]# /etc/init.d/httpd configtest
[root@pasindu svn]# /etc/init.d/httpd restart  


  • Accessing svn over web


http://localhost/svn/repos
if you want configure web svn request over https, you need add above http.conf changes in to ssh.cof or virtualhost.cof file.