Sunday, 1 November 2015

How to setup SVN repository in RHEL7/Centos7



About Subversion [SVN]: Subversion is a free/open source version control system (VCS). That is, 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.


SVN repository configuration:

[root@linuxcnf ~]# yum install httpd subversion mod_dav_svn

Create a directory where want to save SVN data i. e.  /data:

[root@linuxcnf ~]# mkdir /data

Add the below configuration in /etc/httpd/conf.d/subversion.conf for SVN:

[root@linuxcnf ~]# vi /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module       modules/mod_dav_svn.so
LoadModule authz_svn_module     modules/mod_authz_svn.so
<location /data>
        DAV svn
        SVNParentPath /data
        AuthType Basic
        AuthName "SVN Authorization"
        AuthUserFile /etc/svn-auth-users
        AuthzSVNAccessFile /etc/svn-access-control
        Require valid-user
        </location>
[root@linuxcnf ~]# service httpd restart
[root@linuxcnf ~]# chkconfig httpd on

Create a SVN repository:

[root@linuxcnf ~]# svnadmin create /data/testrepo
[root@linuxcnf ~]# chown -R apache.apache /data/testrepo

If you have enabled SElinux execute the below commands:

[root@linuxcnf ~]# chcon -R -t httpd_sys_content_t /data/testrepo
[root@linuxcnf ~]# chcon -R -t httpd_sys_rw_content_t /data/testrepo

Add users for authentication:

[root@linuxcnf ~]# htpasswd -cm /etc/svn-auth-users testuser

Note: use -c option first time only with htpasswd.

Configure svn access control:

[root@linuxcnf ~]# vi /etc/svn-access-control

Create groups to assign permissions:

[groups]
testrepo=testuser

Create access control for users and groups for respected repository:

[testrepo:/]
@testrepo=rw

If you have enabled firewall execute the below commands:

[root@linuxcnf ~]# firewall-cmd -permanent –add -port=80/tcp
[root@linuxcnf ~]# firewall-cmd –reload

Show information about repository:

[root@linuxcnf ~]# svnlook info /data/testrepo

Now we can access the repository with any svn client version using URL (eg. http://<hostname/IP address>/data/testrepo with testuser credentials)

1 comment: