Installing and Configure SVN Server on Centos 6.7 / Redhat 6.x


What is SVN (Subversion)?

Subversion is a free/open-source version control system. Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. 


1. Install the wandisco repo to get the latest version of subversion for CentOS


# vi /etc/yum.repos.d/subsvn.repo

[WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/6/svn-1.8/RPMS/$basearch/
enabled=1
gpgcheck=0


2.  Install needed packages (mod_dav_svn and subversion)

# yum install subversion mod_dav_svn

3. Modify / Create Subversion config file /etc/httpd/conf.d/subversion.conf

Add following config to /etc/httpd/conf.d/subversion.conf file:

vi  /etc/httpd/conf.d/subversion.conf

<Location /svn>
    DAV svn
    SVNParentPath /var/www/svn
       SVNListParentPath On
 AuthType Basic
       AuthName "Subversion repositories"
       AuthUserFile /etc/svn-auth-users
       Require valid-user
</Location>

4. Add SVN (Subversion) users


Add 2 test users so that we can see the different type of permissions 


# htpasswd -cm /etc/svn-auth-users testuser
New password: 
Re-type new password: 
Adding password for user testuser


# htpasswd -m /etc/svn-auth-users testuser2
New password: 
Re-type new password: 
Adding password for user testuser2

5. Create and configure SVN repository


# mkdir /var/www/svn
# cd /var/www/svn
# svnadmin create testrepo
# chown -R apache.apache testrepo

## If you have SELinux enabled (you can check it with "sestatus" command) ##
## then change SELinux security context with chcon command ##

# chcon -R -t httpd_sys_content_t /var/www/svn/testrepo

## Following enables commits over http ##
# chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo

6. Restart the apache to test the configuration 

# service httpd restart

Goto http://localhost/svn/testrepo address and you should see something like following, write username and password:

7. Configure repository

To disable anonymous access and enable access control add following rows to testrepo/conf/svnserve.conf file:

## Edit the testrepo/conf/svnserve.conf ## 
vi testrepo/conf/svnserve.conf

## Disable anonymous access ##
anon-access = none

## Enable access control ##
authz-db = authz

8. Create trunk, branches and tags structure under testrepo


# mkdir -p /tmp/svn-structure/{trunk,branches,tags}

Then import template to project repository using “svn import” command:
Shell


# svn import -m 'Initial import' /tmp/svn-structure/ http://localhost/svn/testrepo/

Setup SVN (Subversion) Access Control with Apache and mod_authz_svn

9. Add SVN (Subversion) users


## Create testuser ##
# htpasswd -c -m /etc/svn-auth-users testuser
New password: 
Re-type new password: 
Adding password for user testuser
## Create testuser2 ##
# htpasswd -m /etc/svn-auth-users testuser2
New password: 
Re-type new password: 
Adding password for user testuser2


10. Create SVN Access Control file


# touch /etc/svn-access-control

vi /etc/svn-access-control


add the following to the files 

[groups]
testreadgroup = testuser

testrwgroup = testuser2

[testrepo:/]
@testreadgroup = are
testrwgroup = rw

[testrepo1:/]
@testreadgroup = r
testuser2 = rw 



11. Add AuthzSVNAccessFile to subversion server config


Add AuthzSVNAccessFile row to config:

vi  /etc/httpd/conf.d/subversion.conf
AuthzSVNAccessFilesvn /etc/-access-control


Finally /etc/httpd/conf.d/subversion.conf file should look something like following:

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn   
   AuthType Basic
   AuthName "Subversion repositories"
   AuthUserFile /etc/svn-auth-users
   AuthzSVNAccessFile /etc/svn-access-control   
   Require valid-user   
</Location>

12. Restart Apache Web Server


# service httpd restart 



Keywords: Subversion, SVN, SVN Server, Adding Users on SVN Server, Backup SVN, Restore SVN.


Comments

Popular posts from this blog

Observium: Configuring Microsoft Windows 2008 Server SNMP Agent

AWS: Introduction to AWS (Amazon Web Services)

System/Server Health Status using PowerShell